Monday, September 22, 2014

Script to get elapsed time from start of current day in SQL Server

How to get elapsed time in Seconds, Minutes, Hours from start of current day?


SELECT DATEDIFF(SECOND, 0, Cast(GETDATE() AS TIME)) -- In Seconds

SELECT DATEDIFF(MINUTE, 0, Cast(GETDATE() AS TIME)) -- In Minutes

SELECT DATEDIFF(HOUR, 0, Cast(GETDATE() AS TIME)) -- In Hours

No comments:

Post a Comment