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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calculating with date/time

Author  Topic 

alexia
Starting Member

2 Posts

Posted - 2004-06-01 : 05:53:09
Hi, Can anyone help me to make a sql query (for a php website) in which to calculate with date and time??
There is: Userid, Begintime, Endingtime and Date. I have to get the hours a month (how much the person has worked that month). So userid x has worked y hours in january... rather nasty... Any help is welcome!

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-06-01 : 05:58:56
In SQL Server Books online look at the Datediff function.


Duane.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-06-01 : 05:59:26
Something like...

select
UserId,
month(Date) as MonthNum,
sum(datediff(hh,StartDate,EndDate)) as hours
from TableA
group by
userid,
month(Date)
Go to Top of Page
   

- Advertisement -