UNIX_TIMESTAMP in SQL Server

后端 未结 8 1969
陌清茗
陌清茗 2020-12-01 15:45

I need to create a function in SQL Server 2008 that will mimic mysql\'s UNIX_TIMESTAMP().

Thanks in advance !

8条回答
  •  感情败类
    2020-12-01 16:33

    Here's a single-line solution without declaring any function or variable:

    SELECT CAST(CAST(GETUTCDATE()-'1970-01-01' AS decimal(38,10))*86400000.5 as bigint)
    

提交回复
热议问题