Calculating timespan with t-sql

You can get the difference between the two dates to whatever resolution you want (in your example, minutes):

DATEDIFF(minute, @start_date, @end_date)

From there it’s a simple matter of dividing minutes into hours and hours into days and modding the remainder.

Leave a Comment