i have table like this
ID Date time
Emp1001 4/25/2012 00:02:12
Emp1001 4/25/2012 00:07:10
Emp1001 4/25/2012 00:08:20
I need to find the total time for the date=4/25/2012
I need the result like this totaltime = 00:17:42
i need query.....
thanks in advance....
Loading
Keyur NarkhiPosted Apr 25, 2012, 5:52 AM
Here is the Query
SELECT EmpId, [Date], RIGHT(REPLICATE('0', 2) + cast(A.H as varchar),2) + ':' + RIGHT(REPLICATE('0', 2) + cast(A.M as varchar),2) + ':' + RIGHT(REPLICATE('0', 2) + cast(A.S as varchar),2) as [Time]
from (
SELECT EmpId, [Date], SUM(datepart(HOUR,[Time])) AS H, SUM(datepart(MINUTE,[Time])) as M, SUM(datepart(SECOND,[Time])) as S
FROM EmpTime
GROUP BY EmpId, [Date]
) as A
Hope this helps.
MuthuMari MPosted Apr 25, 2012, 4:41 AM
pls refer this url
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121027
thanks
If this post is useful then mark it as "Accepted Answer"
Kunal VaishyaPosted Apr 25, 2012, 3:24 AM
After it to Convert into minute hrs
if any confusion then let me know