BradCustom
IS-IT--Management
Hi, thanks for your help with this problem!
I'm using Crystal 2011 and I have a report which shows the actual sales vs. sales goals for a given time period. The time period is defined by the user entering a start and end date into a parameter called InvoiceDate . Typically the start and end of a month. What I would like to do is automatically select the start and end date based on the current date. For example; if I ran the report today 10/17/2016 then my start date would be 10/1/2016 and the end date would be 10/31/2016. below is the formula I'm currently using to calculate the work days between the start and end of range.
I'm using Crystal 2011 and I have a report which shows the actual sales vs. sales goals for a given time period. The time period is defined by the user entering a start and end date into a parameter called InvoiceDate . Typically the start and end of a month. What I would like to do is automatically select the start and end date based on the current date. For example; if I ran the report today 10/17/2016 then my start date would be 10/1/2016 and the end date would be 10/31/2016. below is the formula I'm currently using to calculate the work days between the start and end of range.
Code:
WhileReadingRecords;
Local DatetimeVar Start := {@MinDate}; // place your Starting Date here
Local DatetimeVar End := {Invoice_Header.Document_Date}; // place your Ending Date here
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;
Weeks:= (Truncate (End - dayofWeek(End) + 1
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 2 +
(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 DayOfWeek ( Holidays[i] ) in 2 to 6 and
Holidays[i] in start to end then Hol:=Hol+1 );
Weeks + Days