I want with datediff a result like 26:23 - HOW ??

  • Is there someone who can help me because i'm rather new to SQL (worked always in MS ACCESS) but what I want is the difference between 2 datetime fields expressed as HOURS:MINUTES (the hours can go over 24) and where I can do calculations on (Sum, average, etc). With DATEDIFF i get only an Integer in 1 expression (days or hour or minute, etc)

    Example : 2004-05-11 00:00:00 - 2004-05-09 11:45:00 = 36:15

    Thanks,

    Jan

     

  • Try this query

    declare @dtdiff int

    set @dtdiff = datediff(mi,'2004-05-09 11:45:00','2004-05-11 00:00:00')

    select convert(varchar,@dtdiff/60)+':'+convert(varchar,@dtdiff-((@dtdiff/60)*60))

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply