cancel
Showing results for 
Search instead for 
Did you mean: 

Running a report with current date

Former Member
0 Kudos

Hi Experts,

I have a report with date parameter.When i run the report it is asking for date parameter.

Now i need to run the report with current date instead of date parameter.when i run the report It should run for current date without asking date parameter.

Please suggest an approach.

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

abhilash_kumar
Active Contributor
0 Kudos

Hi Vissu,

If it is report level parameter (parameter created in the CR Designer manually), then just delete it and add the record selection formula with a code like this:

{date_field_in_database} = currentdate

If the Parameter is one that is created by the datasource (like a stored proc with an IN prompt), then you would need to use the Subreport method to pass the current date and stop being prompted for a date value.

1) Create a blank Main Report. Create a formula with this code:

currentdate

2) Insert the original report as a subreport

3) Right-click this Subreport > Go to the Change Subreport Links > Move the formula you created above to the "Fields to link to" pane.

4) From the drop-down where it says "Subreport parameter field to use", choose the date parameter from the Subreport

If you do not see a parameter in the drop-down, it could mean that the parameter's is a datetime prompt and the formula is a date type value. So you would need to change the formula to :

currentdatetime

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

The date parameter is command level parameter and i am using MySQL.

Former Member
0 Kudos

Vissu,

You can put the Command SQL in a sub report and link the command-level parameter to the main report formula as per Abhilash's suggestion.

Thanks

Prathamesh

abhilash_kumar
Active Contributor
0 Kudos

Hi Vissu,

If you don't want to be prompted for a date and instead want the report to run for the currentdate, then remove the command level parameter.

In the SQL, the where clause should then be modified to use a database specific function like CURDATE().

For e.g: Select * from table where date_field = CURDATE()

-Abhilash

Former Member
0 Kudos

Hi

In record selection hard code the follwoing formula

{datefield} = CurrentDate. // currentdate is one of the function from crystal reports

-Shahnawaz

Former Member
0 Kudos

Hi Shahnawaz Sayyed,

Small doubt the Date field means date parameter .Can you please clarify.

Former Member
0 Kudos

Hi,

NO its not the parameter, its the original field from the database which is of date type.

In case if the field is of datetime type then you may use CurrentDateTime

-Shahnawaz