Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Walter writes "Hello,I'm storing time values in a table using smalldatetime. Each record represents a working task from a employee. Table is like:CustomerID(int), ProcessID(int), UsedTime(smalldatetime)1000, 40, 03:15:00At the end of the month i need the sum of UsedTime for every CustomerID. But SUM(UsedTime) doesn't work. How can i get the Total UsedTime of every customer, what have i to do ? I'm really in a panic, i can't find a way to do this. Do you have a solution ? Rgds Walter"
spirit1
Cybernetic Yak Master
11752 Posts
Posted - 2004-10-26 : 09:24:19
there probably is an easier way...
declare @table table (UsedTime datetime)insert into @tableselect '01/01/1900 03:15' union all select '01/01/1900 04:20' union all select '01/01/1900 01:05' union all select '01/01/1900 06:35'select sum(datepart(hh, UsedTime)) + cast(sum(datepart(mi, UsedTime)) as decimal(9,2))/60from @table