SQL Server - converting 13 digit numeric to datetime

前端 未结 3 1772
一向
一向 2021-01-19 07:52

How can I convert a 13 digit numeric like 1314637182953 to datetime in SQL Server? Both casting and converting directly give an arithmetic overflow error!

3条回答
  •  温柔的废话
    2021-01-19 08:22

    Assuming it's UNIX time in milliseconds, try this:

    DATEADD(SECOND, START_DATE/1000 ,'1970/1/1')
    

    For the number from your post, SQL-2008 returns 2011-08-29 16:59:42.000

提交回复
热议问题