Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Cumulative Days With Multiple Begin End Dates Post Reply Post New Topic
Page  of 2 Next >>
Author Message
mrstacy
Newbie
Newbie
Avatar

Joined: 04 Oct 2012
Online Status: Offline
Posts: 9
Quote mrstacy Replybullet Topic: Cumulative Days With Multiple Begin End Dates
     Posted: 04 Oct 2012 at 5:00am

 

I use Crystal Reports 11.

What I'd like to do is get a count of the unique days a patient was enrolled in one of our many programs. if a client was enrolled in 3 programs in which the dates overlapped, i'd just want to count each day once and get a number.

Example using a student:

Algebra Jan 1 to Jan 10: 10 days Science Jan 4 to Jan 11: 8 days English Jan 9 to Jan 13: 4 days

I'd want the answer to be 13.

IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 04 Oct 2012 at 11:49pm
Hi
 
In this case need to find the difference between start date and end date.  Use the following function to find between days.
 
datediff("d", {StartDate},{EndDate})+1
 
or
 
You can directly subtract start date from end date.
 
 
Thanks,
Sastry
IP IP Logged
mrstacy
Newbie
Newbie
Avatar

Joined: 04 Oct 2012
Online Status: Offline
Posts: 9
Quote mrstacy Replybullet Posted: 05 Oct 2012 at 7:36am

My example was too easy.  There will often be gaps in the dates.

New example:
 
Algebra Jan 1 to Jan 4: 4 days Science Jan 7 to Jan 11: 5 days English Jan 9 to Jan 13: 4 days ---> 11 days total
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 06 Oct 2012 at 2:40am
Hope this is possible by using distinctcount of dates
 
 
Thanks,
Sastry
IP IP Logged
mrstacy
Newbie
Newbie
Avatar

Joined: 04 Oct 2012
Online Status: Offline
Posts: 9
Quote mrstacy Replybullet Posted: 08 Oct 2012 at 4:42am
That sounds intriguing.  how would the code look though?
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 08 Oct 2012 at 6:37pm
HI
 
Insert group on student and distinct count the days.
 
Ex :
 
Distinctcount({Table.DateField},{Student}) 
 
 
Place the above formula in student group footer.
Thanks,
Sastry
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Oct 2012 at 4:21am
if you can create a calendar table and join your enrollment table to it so you can get one row per day then the distinct count woud be the way to go. In may ways this would be the easiest solution.
Otherwise I am not seeing a very good solution.
IP IP Logged
mrstacy
Newbie
Newbie
Avatar

Joined: 04 Oct 2012
Online Status: Offline
Posts: 9
Quote mrstacy Replybullet Posted: 09 Oct 2012 at 4:45am
This is what i was thinking to, but how to link to enrollment table when i only have a beginning and end date in that table.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Oct 2012 at 4:53am

use 2 links

enrollment.startdate<=calender.date and enrollment.enddate>=calendar.date
IP IP Logged
mrstacy
Newbie
Newbie
Avatar

Joined: 04 Oct 2012
Online Status: Offline
Posts: 9
Quote mrstacy Replybullet Posted: 09 Oct 2012 at 5:33am
Yes DBlank.  That will work will.  I didn't know you could link like that.  Using greater than and less than links it works. 
 
Put calendar date as first field and studentid as next field.  Then add a crosstab in the footer with studentid as row and do a distinct count on calendar date.
 
i had almost given up.  thanks so much!
IP IP Logged
Page  of 2 Next >>
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