In SQL server you can use directly sum with time object so you can use below logic where first you have to convert tall in minutes and then applying sum and then convert in hour and minute base time forate.
create table #temp(Tm time)
insert into #temp values ( CAST('0:10' as time))
insert into #temp values (CAST('0:55' as time))
select * from #temp
select cast(SUM(DateDiff(MINUTE, CAST('0:00' as time), Tm))/60 as nvarchar(3)) + ':' + cast(SUM(DateDiff(MINUTE, CAST('0:00' as time), Tm))%60 as nvarchar(2)) from #temp
Let me know if you need any more assitance.
My Tech Blogs MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
amitpatel.it
Star
8070 Points
1880 Posts
Re: Sum of Hours in sql server 2008,
Jan 25, 2012 05:30 AM|LINK
In SQL server you can use directly sum with time object so you can use below logic where first you have to convert tall in minutes and then applying sum and then convert in hour and minute base time forate.
create table #temp(Tm time) insert into #temp values ( CAST('0:10' as time)) insert into #temp values (CAST('0:55' as time)) select * from #temp select cast(SUM(DateDiff(MINUTE, CAST('0:00' as time), Tm))/60 as nvarchar(3)) + ':' + cast(SUM(DateDiff(MINUTE, CAST('0:00' as time), Tm))%60 as nvarchar(2)) from #tempLet me know if you need any more assitance.
MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application