How to print GETDATE() in SQL Server with milliseconds in time?

前端 未结 7 564
情书的邮戳
情书的邮戳 2021-02-03 16:49

I want to print GETDATE() in SQL Server 2008, I need the time with milliseconds (this is for debugging purpose - to find sp\'s execution time )

I find this Difference

7条回答
  •  孤独总比滥情好
    2021-02-03 17:18

    This is equivalent to new Date().getTime() in JavaScript :

    Use the below statement to get the time in seconds.

    SELECT  cast(DATEDIFF(s, '1970-01-01 00:00:00.000', '2016-12-09 16:22:17.897' ) as bigint)
    

    Use the below statement to get the time in milliseconds.

    SELECT  cast(DATEDIFF(s, '1970-01-01 00:00:00.000', '2016-12-09 16:22:17.897' ) as bigint)  * 1000
    

提交回复
热议问题