Print Page | Close Window

Date selction problem

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=773
Printed Date: 04 May 2025 at 6:36pm


Topic: Date selction problem
Posted By: ldave
Subject: Date selction problem
Date 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



Replies:
Posted By: BrianBischof
Date 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>


Posted By: BrianBischof
Date 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>



Print Page | Close Window