• george-178499 - Tuesday, March 13, 2018 8:24 AM

    Since the date you are comparing has a precision at the microsecond level you would need to use the precision you are using to determine the difference between dates..

    SELECT DATEDIFF(ms,'2013-04-07 10:45:41.013','2013-04-07 14:00:41.015') /*Difference in Micro seconds between two dates*/
                 ,DATEDIFF(ms,'2013-04-07 10:45:41.013','2013-04-07 14:00:41.015')/1000/60/60 as hrs_diff /*Convert the difference in Micro Seconds as Hours*/
                 ,(DATEDIFF(ms,'2013-04-07 10:45:41.013','2013-04-07 14:00:41.015')/1000/60) % 60 as min_diff /*Gets the residual minutes*/

    Also, your DATEDIFF is choosing milliseconds, not microseconds.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)