cancel
Showing results for 
Search instead for 
Did you mean: 

Default Parameters in Crystal Report

Former Member
0 Kudos

Hi all visitors

I have created one crystal report and now i want to set the parameters to my report by using parameters in Crystal Report( the parameters not from sql).My parameters are datetime datatype. in my report, i create one formula( get date from DocDate field from sql).How can i set the default "Todate" parameter as current date?

Best Regards,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Just leave it blank in the defaults and it should show current date when you run report.

Ian

Former Member
0 Kudos

Thanks for your reply.

Could you tell me for detail about what blank you refer too?

Best Regards,

Former Member
0 Kudos

Not as straight forward as I thought

In CR10 if you went to the Default button and left that dialog blank, when you run the report a date parameter was populated with current date.

However, with CR2008 leaving the Default blank when creating the parameter does not work the same way. When you run report date param is blank.

Try this

In 2008 Create a command to bring back current date

SQL server = select cast(getdate() as date)

Oracle = select trunc(sysdate)

In Parameter set up, use command as your source of parameter data.

Ian

Former Member
0 Kudos

Thanks for your reply.

i already follow your step but when i choose value field in crystal report, it remember the current date but when i change system date to next day.At value field in crystal report will be None. and it remember only one time.

Best Regards,

Former Member
0 Kudos

Hi,

I generally do one of two things in these situations.

A) I create a default parameter that is not a realisitc date (IE Feb 1, 2000 for data that only started populating in 2005) then in the select expert I code using 'if, else, else if' statements to handle the that default date accordingly. If that date is changed then the non-default code is used. I generally use this tactic on reports that I run (not for end users).

B.) I create a parameter called (Use default Parmaeters) which is a Yes or No. If a Yes is selected then other parameters are ingored and default parameters are used (again in select expert) else the other parameters are used. I use this method on reports that users run as the first method can sometimes confuse users.

Good luck!

Former Member
0 Kudos

Thanks for your reply.

Could you tell me for more detail with real example?

because i want like this, all time that the user preview.FromDate parameter will get 1/1/current year as the default and ToDate parameter will get current date as the default

Best Regards,

Former Member
0 Kudos

Hi,

So all of the seleciton is done using selecct expert. They have alot of default values there...but if you go to advanced then you can do much more still. So if you just want to only use the currentdate then you can just do something like

date({IT_ChangeManagement.Deployment Date/Time}) = currentdate

In the above case there would be no parameters needed and would show the currentdates information. You could of course do a varity of >= or <= using the above method.

If you want more flexability then you could create a parameter or two . Here is an example. This is again done in select expert....

if {?Start Date} <= date("01/01/2000") then

(

date({IT_ChangeManagement.Deployment Date/Time}) = currentdate

)

else

(

{IT_ChangeManagement.Deployment Date/Time} >= {?Start Date} and

{IT_ChangeManagement.Deployment Date/Time} <= {?End Date}

)

The above defaults to the current date if the start date is older than 2000, otherwise it uses the start & end date parmeters.

Make sense?

Former Member
0 Kudos

Rody, genius ...

B.) I create a parameter called (Use default Parameters) which is a Yes or No.  If a Yes is selected then other parameters are ignored and default parameters are used (again in select expert) else the other parameters are used. I use this  method on reports that users run as the first method can sometimes confuse users.


... excellent workaround.


Julie

Answers (1)

Answers (1)

Former Member
0 Kudos

hi,

If you want to see the current date as default date value in your parameter,

you could try creating a Prompt in Universe where you can specify the default value.

Pre-requisite : create an object in Universe which gets Current date from your DB.

Use this object as default value in your prompt syntax.

Pull this prompt into your query panel of Crystal report.

Now, when you run you will be able to see currentdate as default value in prompt.

Regards,

Vamsee