Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Selection - Two Different Ways to Choose a Date Range

Status
Not open for further replies.

NewToCrystalX

Technical User
Feb 12, 2009
11
US
I have 2 ways to choose date range.

One - I have a static parameter called {?Last Days} with;

7 (previous 7 days)
14 (previous 14 days)
... and so on.

Then in record selection I have this formula -
{data.timestamp}in currentdate-{?Last Days}to currentdate

Two - I have another parameter called {?Date Range}

Then in Record selection I have
{data.timestamp}={?Date Range}

This brings up two calendars for selecting Start date and end date.


NOW TO MY QUESTION -

I cannot figure out how to use both of these at the same time.

I want the end user to be able to chooses if they want a date range by choosing a start/end date OR by choosing Previous 7 days, etc.

In other words... in record selection, if one range is populated, the other type selection is allowed to be null...or any other way you think this would work.

Thanks in advance.

DMD
 
Having the two tests with an 'OR' should work.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Have a 3rd numeric type parameter - {?Date type} with two options:

1 'Date Range'
2 'Relative Dates'

then in your selection criteria:

If {?Date type} = 1 then
{data.timestamp} in {?Date Range} else
If {?Date type} = 2 then
{data.timestamp} > currentdate-({?Last Days}+1)

You can also then modify headers to take into effect the relevant dates for display purposes etc.

//{@Display date range}
If {?Date type} = 1 then
minimum({?Date Range}) + ' to ' + maximum({?Date Range) else
If {?Date type} = 2 then
currentdate-({?Last Days}+1) + ' to ' currentdate

'J

CR8.5 / CRXI - Discovering the impossible
 
Thanks for the responses.

I had this -

{data.timestamp}in currentdate-{?Last Days}to currentdate or
{data.timestamp}={?Date Range}

If I just use an OR the report errors out and says "PARAMETER HAS NO VALUE" ...pointing to {?Date Range}

I am going to try CR85USER's solution.

Thanks again!!

DMD
 
The solution from CR85USER did the trick!!

I appreciate the help!!

DMD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top