DECLARE @StartTime DateTime = Getdate() -1, @EndTime DateTime = GetDate()
SELECTCONVERT(VARCHAR(6),DATEDIFF(SECOND, @STARTTIME, ISNULL(@ENDTIME,GETDATE()))/ 3600)
+':'+ RIGHT('0' + CONVERT(VARCHAR(6), (DATEDIFF(second, @STARTTIME, ISNULL(@ENDTIME,GETDATE())) % 3660) / 60), 2)
+':'+ RIGHT('0' + CONVERT(VARCHAR(5), DATEDIFF(second, @STARTTIME, ISNULL(@ENDTIME,GETDATE())) % 60),2) AS DURATION
SELECTCONVERT(VARCHAR(6),DATEDIFF(SECOND, @STARTTIME, ISNULL(@ENDTIME,GETDATE()))/ 3600)
+':'+ RIGHT('0' + CONVERT(VARCHAR(6), (DATEDIFF(second, @STARTTIME, ISNULL(@ENDTIME,GETDATE())) % 3660) / 60), 2)
+':'+ RIGHT('0' + CONVERT(VARCHAR(5), DATEDIFF(second, @STARTTIME, ISNULL(@ENDTIME,GETDATE())) % 60),2) AS DURATION
No comments:
Post a Comment