Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date selction problem Post Reply Post New Topic
Author Message
ldave
Newbie
Newbie
Avatar

Joined: 01 Jun 2007
Online Status: Offline
Posts: 1
Quote ldave Replybullet Topic: Date selction problem
    Posted: 01 Jun 2007 at 10:46am
I have a table with several dates Date_1 Date_2... date_52  I need a fromula that lets me calculate the number of occurances if any of these  dates fall into a range selected by the user.( upper date and a lower date). Example user selects the dates 6/12/07 to 8/12/07, how many occurances in this range are present in my date table? if this range matched dates in  Date_1 date_2... Date_40. I would like to return 40 in this instance.
What I am doing now is making a formula to compare each date and then adding them all up.
 
If date_1 in {?Lower date) to {?Upper date} then 1
 
then I add
 
d1+d2+d3....+d52 to get the number of occurances
 
This gives me 52 formulas. Is there a shorter way?
New user
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 01 Jun 2007 at 12:34pm
Since each date is in its own field for the record, then you are doing what is necessary. If they were across multiple fields then you could use a running total calculation to optimize it. But with the given table structure, what you're doing now is best.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 01 Jun 2007 at 12:36pm
Oh yeah - you could create your own function called like "IsInDateRange()" and pass it the date field. That way you only need one formula written. You could do:

IsInDateRange(d1) + IsInDateRange(d2)+...+IsInDateRange(d52)
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.017 seconds.