Hello,
First, I'm a Crystal Novice. That said, I am looking for a way to determine the number of business days in a given date range. However, the date range is variable and set by parameter when running the report.
I am using the Business Days/Holidays code found in one of the FAQs but I don't know how to modify it to reflect the values entered in the parameter for the StartDate and EndDate.
FAQ:
Here is the code from the FAQ:
WhilePrintingRecords;
//Set the values of Start Date and End Date
DateVar StartDate := Date(2003,01,01);
DateVar EndDate := Date(2003,12,31);
//Find out the difference in days and subtract the weekends
NumberVar DaysDiff := DateDiff("d",StartDate,EndDate) -
DateDiff("ww",StartDate,EndDate,crsaturday) -
DateDiff("ww",StartDate,EndDate,crsunday);
//Create an array of Holiday dates
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));
//Loop through the array checking if each holiday is within the dates
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
;
//Display result to 0 decimal places and no thousand separator
totext(DaysDiff,0,"");
Any help would be appreciated.
thanks!
First, I'm a Crystal Novice. That said, I am looking for a way to determine the number of business days in a given date range. However, the date range is variable and set by parameter when running the report.
I am using the Business Days/Holidays code found in one of the FAQs but I don't know how to modify it to reflect the values entered in the parameter for the StartDate and EndDate.
FAQ:
Here is the code from the FAQ:
WhilePrintingRecords;
//Set the values of Start Date and End Date
DateVar StartDate := Date(2003,01,01);
DateVar EndDate := Date(2003,12,31);
//Find out the difference in days and subtract the weekends
NumberVar DaysDiff := DateDiff("d",StartDate,EndDate) -
DateDiff("ww",StartDate,EndDate,crsaturday) -
DateDiff("ww",StartDate,EndDate,crsunday);
//Create an array of Holiday dates
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));
//Loop through the array checking if each holiday is within the dates
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
//Display result to 0 decimal places and no thousand separator
totext(DaysDiff,0,"");
Any help would be appreciated.
thanks!