DATEDIFF FUNCTION to get diffrence in hour and minutes

  • Hi all,,

    How can i use datediff to get diffrence between two dates in hour and minutes??

    thanks

    [font="Comic Sans MS"]
    ---------------------------------------------------

    Thanks [/font]

  • See if this helps

    DECLARE @d1 DATETIME

    DECLARE @d2 DATETIME

    SELECT @d1='20090602 10:23', @d2='20090602 14:24'

    SELECT DATEDIFF(minute,@d1,@d2)/60 AS Hours,DATEDIFF(minute,@d1,@d2)%60 AS Minutes

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537

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

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