Epoch Date Conversion to SQL Server

半腔热情 提交于 2020-01-07 06:18:34

问题


Good Day,

I have a question. What type of epoch date's are these and how would I convert them into a SQL Server datetime format.

37564691530
37564704499
37564708633
37564721033
37564743361
37564746236

I have googled for 2 days and cant find anything except this formula which gives me an arithmetic overflow message when i try to convert it.

select 
    DATEADD(ss, 37564691530 - 3600 * 5, CONVERT(DATETIME, '1900-01-01 00:00:00', 102)) 

Any help would really be appreciated.


回答1:


13 digit epoch represent total milliseconds 10 digit epoch represent total seconds. You have first one - milliseconds. And sql DateAdd function accept second parameter(Increment) as Integer. You try to pass a bigint value. Thats why throw Arithmetic overflow error.

try this

DECLARE @MS BIGINT
SET @MS = 37564746236
select DATEADD(SECOND, @MS / 1000, '1970-01-01')


来源:https://stackoverflow.com/questions/30016815/epoch-date-conversion-to-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!