my code gives TOTAL HOURS in hours, but i am trying to output something like
TotalHours 8:36
where 8 represents hour part and 36 repres
Very simply:
CONVERT(TIME,Date2 - Date1)
For example:
Declare @Date2 DATETIME = '2016-01-01 10:01:10.022' Declare @Date1 DATETIME = '2016-01-01 10:00:00.000' Select CONVERT(TIME,@Date2 - @Date1) as ElapsedTime
Yelds:
ElapsedTime ---------------- 00:01:10.0233333 (1 row(s) affected)