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 |
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2004-10-01 : 05:08:18
|
| Hi,Using the folowing start and end dates, how can I write a sql query to calculate the number of working hours (i.e. 9-5) but EXcluding weekends.startdate: 01/06/2004 08:30:22enddate: 24/06/2004 12:29:34Currently I have a function which works out the number of days excluding the weekends.Thanks |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-10-01 : 05:14:02
|
i think this was posted already, search the forum. |
 |
|
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2004-10-01 : 05:25:41
|
| I believe it was posted for days not hours.Thanks |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2004-10-01 : 05:28:38
|
| You asked for both hours and days I think...Just make a few changes to the code you were supplied...EDIT: Oh and please stop posting duplicates...http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=40692http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=40737http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=40693 |
 |
|
|
tuenty
Constraint Violating Yak Guru
278 Posts |
Posted - 2004-10-01 : 14:48:30
|
Asume every day has 8 hours except for the first and last days (workingDays - 2) * 8hours per day add the hours of the first day + 8 - (difference in hours between 9am and the hour of the starting date) and the hours of the last day + 8 - (difference in hours between the hour of the ending date and 5pm) quote: EDIT: Oh and please stop posting duplicates...
*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*A candle loses nothing by lighting another candle |
 |
|
|
|
|
|