Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateAdd Function adding only business days 2

Status
Not open for further replies.

08211987

Programmer
Apr 20, 2012
187
0
0
US
Hi,
I thought that the following would only add 10 to the week days (business days M-F) but it is adding 10 days including weekends. Is there another way, easy way? I've seen a lot of coding examples but I thought there would be an interval setting that could be used?
Here's my example:
DateAdd("w",10,[tbl_Item_Detail_Calcs]![Item_Setup_Clock_Start])
Thanks!
 
With 10 days you'll always have a weekend in there, possibly 2. I'd write a switch function based on the day of the week that you're starting with.
Switch(format("ddd",[tbl_Item_Detail_Calcs]![Item_Setup_Clock_Start]) = "Sat", DateAdd("w",14,[tbl_Item_Detail_Calcs]![Item_Setup_Clock_Start]),
format("ddd",[tbl_Item_Detail_Calcs]![Item_Setup_Clock_Start]) = "Sun", DateAdd("w",13,[tbl_Item_Detail_Calcs]![Item_Setup_Clock_Start]), format("ddd",[tbl_Item_Detail_Calcs]![Item_Setup_Clock_Start]) = "Mon", DateAdd("w",12,[tbl_Item_Detail_Calcs]![Item_Setup_Clock_Start]), etc.)
I hope that helps.
 
You could use a Function from here to calculate business days M-F.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Thanks Andrzejek! At first I wasn't sure what "TheDate" represented but it works like a charm!
And Laurie, I had never used the Switch function so thanks for teaching me that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top