Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

cast find duration in sql

select 
  EventID, 
  TotalSeconds / 3600 as Hours, 
  (TotalSeconds % 3600) / 60 as Minutes, 
  TotalSeconds % 60 as Seconds
from
(
	select EventID, DateDiff(second, StartDate, EndDate) as TotalSeconds 
	from Events
) x


EventID     Hours       Minutes     Seconds     
----------- ----------- ----------- ----------- 
1           6           11          22
2           7           42          29
3           0           21          6
4           3           51          21
5           1           15          53
6           5           24          0
7           16          50          2

(7 row(s) affected)
Source by www.sqlteam.com #
 
PREVIOUS NEXT
Tagged: #cast #find #duration #sql
ADD COMMENT
Topic
Name
6+3 =