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
When tried to get exact milliseconds we get the overflow exception. we can get the values till seconds and multiply with 1000.
This is equivalent to new Date().getTime() in javascript:
Use the below statement to get the time in seconds.
SELECT cast(DATEDIFF(s, '1970-01-01 00:00:00.000', '2016-12-09 16:22:17.897' ) as bigint)
Use the below statement to get the time in milliseconds.
SELECT cast(DATEDIFF(s, '1970-01-01 00:00:00.000', '2016-12-09 16:22:17.897' ) as bigint) * 1000
convert epoch to human readable date time using below statement:
select DATEADD(s, 1481300537, '1970-01-01 00:00:00')