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 |
ker9
Starting Member
2 Posts |
Posted - 2011-02-15 : 13:29:19
|
Hi, I have employee, start date, end date, Hours. I need a query that will tell me how many of those hours are in each month Beginning 5/1/10 through 4/30/11. If the date range is within the same month, no problem. How do I pull the information out for those ranges that span multiple months? I would have to divide the hours by the number of days to get hours per day. I just don't know how to get to where I need to be.Thank you. |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-15 : 14:33:20
|
Can you provide few rows for the employees table as per specified structure and the desired output format according to that info? |
|
|
ker9
Starting Member
2 Posts |
Posted - 2011-02-15 : 14:49:29
|
emp_lastName sch_clientID sch_fromDateTime sch_toDateTime sch_hours sch_AddMode sch_Monday TEST 1162443281 01/24/2011 01/28/2011 47 1 01/24/2011 TEST 1162436390 01/28/2011 01/28/2011 8 2 01/24/2011 TEST 1162411004 01/31/2011 02/04/2011 15 1 01/31/2011 TEST 28860 01/31/2011 02/04/2011 14 1 01/31/2011 TEST 29641 01/31/2011 02/04/2011 24 1 01/31/2011 TEST 1162436390 01/31/2011 01/31/2011 2 2 01/31/2011 TEST 1162438956 02/07/2011 02/11/2011 55 1 02/07/2011 TEST 1162438956 02/14/2011 02/18/2011 55 1 02/14/2011 TEST 1162410999 02/21/2011 02/25/2011 40 1 02/21/2011 TEST 2385 02/28/2011 03/04/2011 55 1 02/28/2011 TEST 2385 03/07/2011 03/11/2011 55 1 03/07/2011 TEST 2385 03/14/2011 03/18/2011 55 1 03/14/2011 TEST 1162436390 03/18/2011 03/18/2011 2 2 03/14/2011 TEST 2385 03/21/2011 03/25/2011 52 1 03/21/2011 TEST 1162436390 03/25/2011 03/25/2011 3 2 03/21/2011 TEST 2385 03/28/2011 04/01/2011 55 1 03/28/2011 TEST 27435 04/04/2011 04/08/2011 40 1 04/04/2011 TEST 211427 04/11/2011 04/15/2011 55 1 04/11/2011 TEST 211427 04/18/2011 04/22/2011 39 1 04/18/2011 TEST 1162416861 04/25/2011 04/29/2011 40 1 04/25/2011 TOTAL 711 Desired ResultsJan Feb Mar Apr Total47 478 83 12 152.8 11 144.8 19 242 255 5555 5540 40 11 44 5555 5555 552 252 523 3 44 11 5540 4055 5539 3940 40 559 53 88 11 711 |
|
|
|
|
|