>>DATEDIFF(hh,dtStart,dtEnd) returns a value in whole integer hours only.
>>
>>How do I return the value expressed as hh:mm:ss ?
>>
>>Thanks for your help.
>>
>
>Try
CONVERT(char(8), DATEADD(second, DATEDIFF(second, dtStart, dtEnd), '20020101'), 8)
Sergey,
Yes. That works well up to 23:59:59 as in the following.
declare @dtStart datetime
declare @dtEnd datetime
set @dtstart = '01/01/2002 9:00:00'
set @dtEnd = '01/02/2002 8:49:00'
SELECT CONVERT(char(8), DATEADD(second, DATEDIFF(second, @dtStart, @dtEnd), '20020101'), 8)
I really didn't ask it right. I had in mind something that would calculate for any number of hours.
Something that would present partial hours as decimals would be useful for my task also. For example, where 25 hours and 15 minutes = 25.25 hours.
I'm glad that you're thinking well. Thank you! Thank you!