Use the following formula, replacing the items in Bold with your start/end date and the items in Italics with your holidays........
WhilePrintingRecords;
[color green]//Set the values of Start Date and End Date[/green]
DateVar StartDate := Date(2003,01,01);
DateVar EndDate := Date(2003,12,31);
[color green]//Find out the difference in days and subtract the weekends[/green]
NumberVar DaysDiff := DateDiff("d",StartDate,EndDate) -
DateDiff("ww",StartDate,EndDate,crsaturday) -
DateDiff("ww",StartDate,EndDate,crsunday);
[color green]//Create an array of Holiday dates[/green]
Local DateVar Array Holidays := MakeArray( Date(2003,01,01),
Date(2003,01,02),
Date(2003,12,25),
Date(2003,12,26),
Date(2003,07,07));
[color green]//Loop through the array checking if each holiday is within the dates[/green]
Numbervar Counter := 0;
While UBound(Holidays) <> Counter do
(Counter := Counter + 1;
if Not(dayofweek(Holidays[Counter]) in [1,7]) and
Holidays[Counter] in StartDate to EndDate then DaysDiff := DaysDiff -1;
[color green]//Display result to 0 decimal places and no thousand separator[/green]
totext(DaysDiff,0,"");
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.