CREATE TABLE Timing (
StartTime DATETIME
,EndTime DATETIME
,ResultTime BIGINT
,ElapsedTime VARCHAR(20)
)
insert into Timing (StartTIme, endtime) values
('2014-11-20 14:35:42','2014-11-28 14:36:15')
DECLARE @MyNullTime TIME
SET @MyNullTime = '00:00:00'
SELECT StartTime,EndTime
,DATEDIFF(MILLISECOND, starttime, EndTime) AS 'tResultTime (MS)'
,cast(DATEDIFF(HOUR, starttime, EndTime) / 24 AS VARCHAR(5)) + 'day(s) '
+ cast(DATEADD(SECOND, - DATEDIFF(SECOND, EndTime, StartTime), @MyNullTime) AS VARCHAR(8)) AS 'Elapsed Time'
FROM timing
-Vaibhav Chaudhari
No comments:
Post a Comment