WoodyGuthrie
MIS
I have no problem getting "elapsed Time" like this:
CONVERT(Varchar,EndTime - StartTime ,108) As ElapsedTime
My problem is getting "Delay Time". This calculation can result in a positive hh:mm:ss but can also be negative (hh:mm:ss) as is the case when StartTime is earlier than the ScheduledTime. When I use the following and use DateDiff with the Hour parameter, I can get -3, for example, when the StartTime is 7:30:15AM and the ScheduledTime is 10:12:23AM. But how do I get hh:mm:ss? Obviously, I suppose NOT by using DateDiff. Can this be done without getting into the gastly stuffs, replaces,etc.?
----------------------------------
Case
When StartTime < ScheduledTime /*Negative Delay Time*/
Then Convert(Varchar, DateDiff(Hour,ScheduledTime, StartTime),108)
When StartTime >= ScheduledTime /*Positive Delay Time*/
Then Convert(Varchar,StartTime - ScheduledTime,108)
End as DelayTime
-------------------------------------
Thanks in advance for any help.
CONVERT(Varchar,EndTime - StartTime ,108) As ElapsedTime
My problem is getting "Delay Time". This calculation can result in a positive hh:mm:ss but can also be negative (hh:mm:ss) as is the case when StartTime is earlier than the ScheduledTime. When I use the following and use DateDiff with the Hour parameter, I can get -3, for example, when the StartTime is 7:30:15AM and the ScheduledTime is 10:12:23AM. But how do I get hh:mm:ss? Obviously, I suppose NOT by using DateDiff. Can this be done without getting into the gastly stuffs, replaces,etc.?
----------------------------------
Case
When StartTime < ScheduledTime /*Negative Delay Time*/
Then Convert(Varchar, DateDiff(Hour,ScheduledTime, StartTime),108)
When StartTime >= ScheduledTime /*Positive Delay Time*/
Then Convert(Varchar,StartTime - ScheduledTime,108)
End as DelayTime
-------------------------------------
Thanks in advance for any help.