current date as default parameter

Hi,

How can we have current date as default date in the date parameter ?? I need is to show the current date as the default value for the date field in the parameter window.

Regards


mminhajm (BOB member since 2009-03-06)

You can’t display the actual current date as the default value as Crystal parameters don’t allow selection of functions as default value.

If this is a universe based report, you can create a filter object like this:

table.datefiled =
case when @prompt(‘Enter date’,‘A’,mono,constrained,persistent,{‘Current Date’},) = ‘Current Date’ then getDate()
else @prompt(‘Enter date’,‘A’,mono,constrained,persistent,{‘Current Date’},)
end

What this does is presents the user with a date prompt whose default value is set to a static text ‘Current Date’. If the user selects this value then the case statement will compare the database field with getDate() SQL function. You will have to apply some kind of formatting to getDate() function to convert it to the same date format as the database values.

If the user doesn’t select Current Date rather enters a valid date, database value will be matched to the entered value.

The only drawback to this approach is that the user will not get a calendar control on this prompt since the type is defined as alphanumeric.

Hope this helps.


Farhan Jaffery :us: (BOB member since 2005-08-27)