cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report parameter default to today - 7

0 Kudos
201

I have a report with one input parameter. I need the default parameter value to be todayDate - 7 if the field is blank. Is there a way to set this field to have the date in the report when it is first open?

Can I set a todays date - 7 inside this field?

View Entire Topic
DellSC
Active Contributor
0 Kudos

Try this:

1. Make the parameter optional. This will default to null if there is no value.

2. Edit the formula in the Select Expert. It will look something like this:

(
  (HasValue({?Date}) and {MyTable.DateField} = {?Date})
  OR
  (not HasValue({?Date}) and {MyTable.DateField} = ToText(CurrentDate - 7, 'yyyyMMdd')
)

Note how I've used parentheses here - because this is an OR statement, the parentheses are very important for getting it to work correctly.

-Dell