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 Page Setup dialog box to set the page margins for your report.