Search code examples
crystal-reportsdate-range

Crystal date based record selection; no lower date through Saturday


I want to set up a Crystal report with a default date range for record selection. I want the date range to be no lower date through Saturday of the current week based on the formula field {@Calc Promise Date}. I am a lighter end user of Crystal and am having trouble with this.

I can use:

{@Calc Promise Date} in AllDatesToToday

But I am looking for a way to have the results be all dates to Saturday of the current week.

Thanks in advance for your help.


Solution

  • Thanks to help from Siva on a similar question, I now have the answer for this one. Make a new Formula Field of "End Date" that contains:

    if DayOfWeek (DateSerial(Year(currentdate),Month(currentdate),Day(currentdate))) = 1
    then DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+6)
    else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),Day(currentdate))) = 2
    then DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+5)
    else if  DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),Day(currentdate))) = 3
    then DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+4)
    else if  DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),Day(currentdate))) = 4
    then DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+3)
    else if  DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),Day(currentdate))) = 5
    then DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+2)
    else if  DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),Day(currentdate))) = 6
    then DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+1)
    else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),Day(currentdate))) = 7
    then DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+0)
    

    Then in Record Selection reference that formula. In my case, the correlating date range for the records was a Through Current Date Range formula field, so my Record Selection was then updated to include the following line:

    {@Through Current Date Range}<{@End Date}