Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Calculaing difference in time
Thu, Mar 4 2010 4:22 AMPermanent Link

Stenstrup

Hi
I have the following table:

StartTime StopTime
10:00:00   10:32:20
10:55:12   11:13:55
11:21:04   11:25:41

I want to calculate the difference in time from the first StopTime to the next StartTime!!!

Like this:

StartTime StopTime IdleTime
10:00:00   10:32:20  00:00:00
10:55:12   11:13:55  00:22:52
11:21:04   11:25:41  00:07:09

Thanks
Thu, Mar 4 2010 12:23 PMPermanent Link

John Hay

Stenstrup
> Hi
> I have the following table:
>
> StartTime StopTime
> 10:00:00   10:32:20
> 10:55:12   11:13:55
> 11:21:04   11:25:41
>
> I want to calculate the difference in time from the first StopTime to the
next StartTime!!!
>
> Like this:
>
> StartTime StopTime IdleTime
> 10:00:00   10:32:20  00:00:00
> 10:55:12   11:13:55  00:22:52
> 11:21:04   11:25:41  00:07:09

Something like the following should do it

select starttime,stoptime,
right('0'+cast(hoursfrommsecs(stoptime-starttime) as
char(2)),2)+':'+right('0'+cast(minsfrommsecs(stoptime-starttime) as
char(2)),2)+':'+right('0'+cast(secsfrommsecs(stoptime-starttime) as
char(2)),2) from table

John

Image