BOFocus – Crystal Reports Tips – Tricks – Tutorials

Crystal Reports - Formulas

Calculating the number of working days

The following will calucalate the number of working days between two dates. Simple replace {start_date} & {end_date} with your date fields or the dates you wish to use:

Numbervar Workingdays := 0;
Datevar d1 := {start_date};
Datevar d2 := {end_date};
Numbervar x := 0;
Numbervar days := datediff(“d”, d1, d2);
Numbervar Array Weekdays := Makearray(2,3,4,5,6);

While x <= days Do (
If Dayofweek(Dateadd(“d”, x, d1)) In Weekdays Then  
WorkingDays := WorkingDays + 1;  x := x + 1; );



Tagged , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Use the Chart Sort Order dialog box to sort and group your chart data. This dialog box appears when you click the Order button on the Data tab of the Chart Expert for a chart with the Advanced layout type.