Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Counting Days in a table between 2 parameter dates Post Reply Post New Topic
Author Message
troyguy2
Newbie
Newbie


Joined: 29 Mar 2011
Online Status: Offline
Posts: 3
Quote troyguy2 Replybullet Topic: Counting Days in a table between 2 parameter dates
     Posted: 29 Mar 2011 at 6:12am
I've been trying to figure this out for a few days now, and have had no luck.

We have a Table here at work called "Working_Day".  within it, is only 1 field that lists all the working days that we operate.  It excludes weekends, and holidays. (has been pre-populated until sometime in 2020, all the way back from 1990)

What I need to do is, count the number of days within the table using a subreport between two given parameter dates. 

Example:

Date range of March 1st 2006 - April 15th 2006.

I'd have a parameter for the start date and end date (StartDate, EndDate), and those parameters pass into the subreport.

Now, in the database, i need it to count each date within the table that exists between those two dates.  I know using this example, the result should be 32.  But i just cant figure out the logic to make this work.

I'm a bit new to Crystal Reports, and this has been the hardest thing to figure out so far. Google hasn't been a great help either.

Any suggestions are much appreciated, and thank you.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Mar 2011 at 6:31am
when you say you have one field with all the days do you mean you have one row per day or is it one gianty blob field with all the dates listed withj comma seperators or something similar?
assuming it is one row per date what is the field type and or field format?

Edited by DBlank - 29 Mar 2011 at 6:32am
IP IP Logged
troyguy2
Newbie
Newbie


Joined: 29 Mar 2011
Online Status: Offline
Posts: 3
Quote troyguy2 Replybullet Posted: 29 Mar 2011 at 7:04am
My bad - One row per day.

field format: mm/dd/yyyy
field type: date
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Mar 2011 at 7:08am
make a parameter as a date field called "begin date"
make another parameter as a date field called "end date"
(or you can make once param set to allow for a range if you want)
 
in the select expert
{table.datefield} in {?begin date} to {?end date}
do a distinct count of the date field and it is the number of days
IP IP Logged
troyguy2
Newbie
Newbie


Joined: 29 Mar 2011
Online Status: Offline
Posts: 3
Quote troyguy2 Replybullet Posted: 30 Mar 2011 at 9:41am
Got me going in the right direction... thank you!  
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