SQL Server datetime to bigint (epoch) overflow

后端 未结 4 1995
春和景丽
春和景丽 2020-12-01 19:15

I have a \'datetime\' column with value 2013-03-22 15:19:02.000

I need to convert this value into epoch time and store it in a \'bigint\' field

The actual e

4条回答
  •  天涯浪人
    2020-12-01 19:49

    Use below code to get human readable date from epoch time

    select DATEADD(s,convert(bigint,@date)/2, DATEADD(s, convert(bigint,@date)/2, '1970-01-01 00:00:00'))
    

提交回复
热议问题