Sorry second Post, complete this time
WhilePrintingRecords;
DateVar Start := {@Date_termine};
DateVar End := {@Date_Promise};
Numbervar Tot;
NumberVar Weeks;
NumberVar Days;
NumberVar Hol:= 0;
//Figure the number of Calendar "Rows" involved and count 5 days for each:
Weeks:= (Truncate (End - dayofWeek(End) + 1 - (Start - dayofWeek(Start) + 1)) /7 ) * 5;
//Adjust the first and last weeks based on when in the week you start and end
Days := DayOfWeek(End) - DayOfWeek(Start)
+ (if DayOfWeek(Start) = 1 then -1 else 0) //adjust for starting on a Sunday:
+ (if DayOfWeek(End) = 7 then -1 else 0); //adjust for ending on a Saturday:
//Adjust for Holidays in the period between the start and end dates:
if Date(2002,01,01) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2002,01,18) in start to end then Hol:= Hol+1 else Hol:= Hol;
etc...
//Assemble the adjusted work days
Tot:=Weeks + Days - Hol;
If Tot < -1000 then 0
else if Tot > 1000 then 0
else Tot
Hope this help !
Jean-Paul Leboeuf
jleboeuf@iquebec.com