i'm new to SQL ecpeialy on DATE related operation
In my table starttime and endtime two columns are there, i need to find sum of total hours group by employeename.
how can i do this?
exm: EmpName Starttime EndTime
A 14/2/2012 25:20:00 14/2/2012 25:20:00
A 15/2/2012 20:20:00 15/2/2012 25:20:00
But i need output as
EmpName TotalHours
A 20:25:32(eg)
please help.............
How to find Total hours?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Kunal VaishyaRank #990 · 2K reputationPosted May 15, 2012, 12:57 AM EDT
Select UserCode,Cast((DateDiff(mi,Starttime,EndTime) / 60) As Varchar(8)) + ':' +
Cast((DateDiff(mi,Starttime,EndTime) % 60) As Varchar(2)),Starttime As [In Time],EndTime As [Out Time ]From tblLogIn
Gohil JayendrasinhRank #490 · 5K reputationPosted May 14, 2012, 11:16 PM EDT
use datediff like
select
sum(Datediff(hour,StartingDate,EndingDate)) from ItemDiscountSenthilkumarRank #387 · 6.5K reputationPosted May 15, 2012, 12:04 AM EDT
Note that when you use the HH will give the date difference in hours. But it needs something like entire different between two dates.
I think get the seconds or minutes and find the differences, so you can calculate the actual time different by diving the minutes.