Showing results for 
Search instead for 
Did you mean: 

calculating number of days without weekend and holidays

Former Member
0 Kudos

Hallo all,

can someone help me with a formular to calculate the number of days with Crystal Reports 2008 between two dates without weekends and holidays


date one = 03/24/2010

date two = 03/29/2010

Result should be 4 days as 03/27 and 03/28 will be a weekend.

Plus how to exclude holidays ?

Thank you very much


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The DateDiff function can be used to get the number of days skipping weekends.

The Help Text for that function actually has an example, but basically you use the "d" interval type to get the absolute number of days, then the "ww" interval type to get the number of Saturdays, the same for Sundays and subtract those 2 counts from the first.

Holidays are so location specific that you'd have to handle those in some manual way. Perhaps load your holidays into an array, then run through the array and check if each date falls in your date range. I have no example of this or experience doing it!

Edited by: Doug McLauchlan on Mar 26, 2010 9:40 PM - Spelling

Former Member
0 Kudos

As Doug mentioned, Holidays are very location specific, and are you talking about "corporate holidays" where the company is closed, or "public holidays" where banks (<g>) are closed?

I'd suggest setting up a calendar table (if you don't have one already), one record per date. You could make it work-days only, days-off only, or all dates with a flag to indicate if it is a work date. You could then use that to count the number of work days. By using a table, you wouldn't have to change any code to (a) extend your calendar to the following year, or (b) change holiday dates if the holidays change. (I'm thinking corporate holidays, where the company might be closed Friday 12/24/10 in observation of Christmas, but would usually only close on the 25th.)



Answers (0)