I have to calculate the future ship date based on how many days of inventory we have on a product. I already have a field which tells me how many days I have left of inventory on a product. It's not as simple as just adding that to 'currentdate', because I must calculate the shipdate in business days.

So if today is Monday, and I have 7 days worth of inventory left...that means that my ship date would be next Wednesday.

Currently I have a formula which takes out weekends and holidays, however I guess I sort of need to reverse it...


WhileReadingRecords;
Local DateVar Start := {?Month}; // place your Starting Date here
Local DateVar End := CurrentDate; // place your Ending Date here
Local DateVar EndOther;
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;
Numbervar TotDays;

Weeks:= (Truncate (End - dayofWeek(End) + 1
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 +
(if DayOfWeek(Start) = 1 then -1 else 0) +
(if DayOfWeek(End) = 7 then -1 else 0);

Local NumberVar i;
For i := 1 to Count (Holidays)
do (if Holidays[i] in start to End then Hol:=Hol+1 );
);

TotDays := Weeks + Days - Hol;