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 |
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2005-11-18 : 08:20:40
|
| Is there a better way to calculate a future date that ignores weekends other that using datepart to test for the day?Example:Add 7 to 04/05/2006 results in 11/05/2006But if the weekend is ignored you would get 12/05/2006I can just add 8 instead as it could end up with the end date landing on a weekend. I need to calculate working days only as we dont work weekends.Thnx for any tips :) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2005-11-18 : 08:40:04
|
| Thnx :)I have tried this but get error Line 2: Incorrect syntax near '04/05/2006'declare @T intselect @T = calculate_weekday '04/05/2006', '12/05/2006'print @TI have tried omitting the quotes, adding # etc.DOH! how do you pass a date :( |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-18 : 08:49:35
|
| Which function are you using?Try thisdeclare @T intselect @T = dbo.calculate_weekday_function ('04/05/2006', '12/05/2006')print @TMadhivananFailing to plan is Planning to fail |
 |
|
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2005-11-18 : 08:56:39
|
| I'm using the function code in the centre of the post you sent.If I run this I get 6, have to use American date format tho! The six would suggest it does not include the first date? I make it as being 7?declare @T intselect @T = dbo.calculate_weekday('05/04/2006', '05/12/2006')print @T |
 |
|
|
|
|
|