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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding x Working Days to a specific date

Status
Not open for further replies.

jms1

MIS
Feb 24, 2003
4
0
0
GB
I want to add a leadtime eg 10 working days to an order date. I can add 10 calendar days using the DateAdd function
DateAdd("d", 10, #Sept 28, 1999#)but need to know how to add 10 weekdays.
 
This is my solution from thread767-718833 :


This should work for you:

Local DateVar StartDate := Date(2003,11,27);
Local NumberVar NetDays := 5;
Local NumberVar Counter := 0;

While Counter <> NetDays do
(if Dayofweek(StartDate+Counter) in [1,7] or
StartDate+Counter in [Date(2003,12,02),Date(2003,12,03)] then NetDays := NetDays + 1;
Counter := Counter +1;);

StartDate+NetDays;

Replace items in bold with your fields and items in italics with your holiday days.....

Reebo
UK

&quot;Before you judge a man, walk a mile in his shoes. After that, who cares? ...He's a mile away and you've got his shoes.&quot; - Billy Connolly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top