Calculating timespan with t-sql

前端 未结 7 1791
时光取名叫无心
时光取名叫无心 2020-11-30 07:32

Given two date/times:

@start_date = \'2009-04-15 10:24:00.000\'
@end_date = \'2009-04-16 19:43:01.000\'

Is it possible to calculate the tim

7条回答
  •  伪装坚强ぢ
    2020-11-30 07:41

    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.

提交回复
热议问题