Skip to Content
Former Member
Apr 18, 2008 at 04:56 PM

Working days formula and Crystal 7 - is it possible?


Post Author: Tim F

CA Forum: Formula

Hi folks,

Really hope someone can help, I'm struggling with writing a report that needs to show the difference between two dates in working days. I've found the same formula posted here several times but cannot get it to return a logical value in my report. I'm wondering if that might be because I'm using an older version of Crystal? The formula in question is this one:

//Main formulaWhileReadingRecords;Local DateVar Start := ({PPV_COMPLAINTSEH.DTRECD}); Local DateVar End := ({PPV_COMPLAINTSEH.ACTCMPLTD}); 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) + 1 + (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 );

Has anyone come across an alternative way of doing this, or have any ideas why this formula is not working in my report? Any advice would be much appreciated,