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.
| Author |
Topic |
|
ninel
Posting Yak Master
141 Posts |
Posted - 2005-06-28 : 12:35:04
|
| I have the following table:Employee Login Logout1 08:00:00 13:30:002 09:25:00 16:25:003 13:00:00 19:00:00How can I add these up to get a total calltime that looks like this:Emp1: 05:30:00Emp2: 07:00:00Emp3: 06:00:00Thanks,Ninel |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-28 : 12:37:50
|
select employee, logout-login as difffrom MyTableGo with the flow & have fun! Else fight the flow |
 |
|
|
nosepicker
Constraint Violating Yak Guru
366 Posts |
Posted - 2005-06-28 : 22:14:43
|
| Your login and logout times are probably character data columns, so slightly modifying Mladen's nicely succinct query, you will probably have to do this:SELECT employee, CONVERT(char(8), CONVERT(datetime, logout)-CONVERT(datetime, login), 108) AS diff FROM MyTableBTW Mladen, I answered this same question on a different forum, but I used DATEDIFF with DATEADD. Your query is a little more efficient, so kudos to you! |
 |
|
|
|
|
|