Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

business days difference? 1

Status
Not open for further replies.

PAULCALLAGHAN

Technical User
Sep 4, 2001
165
CA
I'm using crystal reports version 8.5 and downloaded files from cr_business_days_hours.zip from the Business Object website so that I can calculate the number of business days between two dates.

I'm having trouble understanding the special ufl/formula. I have typed in everything it says in the documentation but it won't work.

It says " Replace 'Enter Text File Path' with your path to your Holidays text file. "

What does this mean exactly? I can't find an example and I have typed in different things but nothing works. What am I doing wrong? Can someone please explain what they mean? what should I type in here?

Is there another kb document/article that could help me here?
 
Paul,

I think I used the same code on one of my reports.

Days available:

//Main formula
WhileReadingRecords;
Local DateVar Start := {@PeriodStart}; // place your Starting Date here
Local DateVar End := {@PeriodEnd}; // 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) + 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 Holidays in start to end then Hol:=Hol+1 );

Weeks + Days - Hol


and Holidays:

//Holiday Listing formula to go into the report header of the report.
BeforeReadingRecords;
DateVar Array Holidays :=
[Date (2004,12,27),
Date (2004,12,28),
Date (2005,01,3),
Date (2005,01,26),
Date (2005,03,25),
Date (2005,03,28),
Date (2005,04,25),
Date (2005,06,13),
Date (2005,11,1),
Date (2005,12,26),
Date (2004,04,09),
Date (2004,11,02),
Date (2004,06,14),
Date (2004,04,12)
];
0

{@PeriodStart}is the min of your date range parameter and
{@PeriodEnd}is the max.

Dates are Australian holidays for 2005 so you probably need to change them.

hope it works for you,


David


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top