Is this needed for the main report?
mlmcc
Main Topics
Browse All TopicsI am writing an On-Time Shipments report and have to determine how many business days have lapsed between the requested-date and the shipped-date, minus weekends and holidays.
I have a holiday table with all holidays entered for the next several years. Therefore, I can't use a piece of code that hardcodes the holidays in it (like this one: http://www.kenhamady.com/f
Does anybody have a formula I can use? The link that has answered this frequent question on EE is broken so that's no help (http://support.businessob
Thanks much,
MTaft
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Basic idea of the formula. James was thinking along the same basic lines.
In the main report
Right click the report header left margin
Click INSERT SECTION BELOW
Repeat
You should now have
RHa, RHb, RHc
In RHa
WhilePrintingRecords;
Shared DateVar Array Holidays;
""
In RHb add the subreport
In the subreport details add a formula
WhilePrintingRecords;
Shared DateVar Array Holidays;
Local NumberVar CurrentSize;
CurrentSize := UBound(Holidays);
ReDim Preserve Holidays[CurrentSize+1];
Holidays[CurrentSize+1] := {DateField};
""
Use RHc for the main report report header
mlmcc
Yep, he's right. That's the basic idea. When the subreport finishes, the Holidays array should have all of the dates from your holiday table in it, and since it's a shared variable, you can use it in formulas in the main report. The only remaining detail is that you have to make sure that you also declare the Holidays array as Shared in your formula to calculate the business days, meaning that you'll have to change the declaration in the formula on Ken Hamady's site. Otherwise, CR will create a new Holidays array (separate from the one in the subreport) and you won't get the dates from your table.
James
I was wondering why you asked if this was for the main report. I thought you might be thinking of using a subreport too, but I didn't see why it mattered if you were going to calculate the days in the main report or a subreport. I get it now. For my idea it wouldn't matter, but for yours it would.
James
Business Accounts
Answer for Membership
by: PCIRichardPosted on 2009-08-12 at 14:25:23ID: 25083201
To count weekdays only, use the following formula:
DateDiff ("d", {due_date}, {despatch_date}) -
DateDiff ("ww", {due_date}, {despatch_date}, crSaturday) -
DateDiff ("ww", {due_date}, {despatch_date}, crSunday)
I'll thik about the holidays....