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.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Sum of Time Value

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-26 : 13:03:12
Dear All,
I have one table with this structure

Log_Id - Task - Total_Time_Spent(HH:MM:SS)
A1-T1-00:15:01
A2-T2-02:09:09
A3-T3-01:59:54
A1-T1-02:05:25
A1-T1-02:08:26

Now i have to check log_id wise total time spent.

How should i do?


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-26 : 13:06:55
[code]SELECT Log_Id,SUM(DATEDIFF(ss,0,Total_Time_Spent))
FROM table
GROUP BY Log_Id
[/code]
Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-26 : 13:39:57
But i want anser to be in HH:MM:SS Format
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-26 : 15:41:08
SELECT Log_Id,
CONVERT(CHAR(8), DATEADD(SECOND, SUM(DATEDIFF(SECOND, 0, Total_Time_Spent)), 0), 8)
FROM table
GROUP BY Log_Id



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-27 : 12:16:14
Thanks
Go to Top of Page
   

- Advertisement -