TSQL - Conversion of Epcoh to Datetime
Convert Current UTC date to Epoch
SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE())
SELECT DATEDIFF(s, '19700101', GETUTCDATE())SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE())
Convert Epoch to dateTime
select dateadd(ss, epoch, '19700101')
SELECT DATEADD(s, epoch, '1970-01-01 00:00:00')
Example
select dateadd(ss, 1394796484, '19700101')
SELECT DATEADD(s, 1393345800, '1970-01-01 00:00:00')
Comments
Post a Comment