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 Programming
 Sum on DateTime.

Author  Topic 

BendJoe
Posting Yak Master

128 Posts

Posted - 2010-08-20 : 15:39:54
I have a table.
EmployeeID(int),Day(datetime),Login(datetime),Logout(datetime)

I need the total time in hrs:min:secs that an employee was logged in.
I need to consider that the employee could login and log out as many times as he wants a day.

Result should be like
EmployeeID, Date, LoggedTime.
Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-20 : 15:50:09
Use DATEDIFF to get the number of minutes between each login and logout, SUM it up, GROUP BY EmployeeId and the date.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -