Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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.
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 hoursfrom TableAgroup by userid, month(Date)