Click here to Skip to main content
15,912,665 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have column(time datatype) which contains values like 9:25:03 4:43:21 2:50:13 11:25:33 ,what query should i write to get sum of all values in the column
Posted

1 solution

Check this

SQL
create table timed
(hou time)


insert into timed values('9:25:03')
insert into timed values('11:25:33')

select  cast(sum(datediff(second,0,hou))/3600 as varchar(12)) + ':' +
        right('0' + cast(sum(datediff(second,0,hou))/60%60 as varchar(2)),2) +
        ':' + right('0' + cast(sum(datediff(second,0,hou))%60 as varchar(2)),2)
from    timed
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900