Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Work Days between two dates, Public Hols in table Post Reply Post New Topic
Author Message
bowja
Newbie
Newbie
Avatar

Joined: 07 Dec 2009
Location: Australia
Online Status: Offline
Posts: 31
Quote bowja Replybullet Topic: Work Days between two dates, Public Hols in table
     Posted: 02 Oct 2013 at 3:11pm
Hi Everyone,

I am sorry if this is a duplicate of another question but I haven't been able to find the solution on this or other forums.  I expect this is due to my inexperience with writing loop formulas.  Happy to be directed to an existing solution.

In my report the user enters to and from dates producing a set of results.  The results are "jobs" finished in the date range.  The result has two columns commence date and complete date.  I then want to add a column to display the number of working days between.  Not accounting for holidays this was easy, I just subtracted the Sat and Sun count from the total datediff.

The part I cannot work out is how to subtract the number of weekday public holidays.

All public holidays are recorded in a separate db table which lists the date and the name i.e. 2013-12-25||Christmas Day etc.

I believe Ken Hamady has published a solution using an array however I am not sure how to produce the array from my db table or reference the table directly.

"http://www.kenhamady.com/form01.shtml"

Kind Regards,

bowja

If you think you can or think you can't you are right - Paraphrased quote Henry Ford
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Oct 2013 at 5:18am
in a stored procedure I can see this not being too difficult, but from inside a report...I'm not sure...perhaps with a subreport???

This is the general idea, which may not work...
in the subreport you have the table of holidays. Pass in the dates from the main report as parameters. in the subreport have a formula like:
if {table.holidayDate} in {@fromDate} to {@toDate} then
1
else
0

then in subreport groupfooter:
shared numbervar holidays:= sum(formulaName);
""//will hide the output if you want

back in the main report, where you calculate the days:
shared numbervar holidays;

existing logic - holidays

it nothing else, it's worth a try.

as a caveat, it will slow down the report, but all subreports do, which is why I try and avoid them, and sometimes that just can't be done.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum