DateTime's representation in milliseconds?

后端 未结 7 830
遥遥无期
遥遥无期 2020-11-30 05:21

I have a SQL-server timestamp that I need to convert into a representation of time in milliseconds since 1970. Can I do this with plain SQL? If not, I\'ve extracted it into

相关标签:
7条回答
  • 2020-11-30 06:05
    SELECT CAST(DATEDIFF(S, '1970-01-01', SYSDATETIME()) AS BIGINT) * 1000
    

    This does not give you full precision, but DATEDIFF(MS... causes overflow. If seconds are good enough, this should do it.

    0 讨论(0)
提交回复
热议问题