· 1 min read
T-SQL: Calculate Hours, Mins and Secs from StartTime and EndTime
sum(TotalSeconds) / 3600 as Hours,
(sum(TotalSeconds) % 3600) / 60 as Minutes,
sum(TotalSeconds) % 60 as Seconds
select ArrivalTime, DepartureTime, DateDiff(second, ArrivalTime, DepartureTime) as TotalSeconds
where CustomerID = 10
Thanks to this site for the heads up.