Microsoft SQL Server Tips

 Find Hours, Minutes and Seconds in between two datetime
    --// Declaration
    DECLARE @First    DateTime
    DECLARE @Second DateTime
    Declare @t        BigInt
    --// Initialization
    SET @First    = '17 Feb 2011 00:00:00'
    SET @Second = '18 Feb 2011 12:03:28'

    --// Preparation
    Select @t = DateDiff(Second,@First,@Second)  -- Take Second Difference

    Select Cast((@t / 3600) As Varchar(Max)) + ':' +     -- Hour

    Cast((@t - (@t / 3600) * 3600) / 60 As Varchar(Max)) + ':' +   -- Minute

    Cast(@t - ((@t / 3600) * 3600) - ((@t - (@t / 3600) * 3600) / 60) * 60  As Varchar(Max)) -- Second
    As Duration