Crystal Reports – Prompt and Filter by Date

The following guide describes how to create a Crystal Report which will prompt for a FROM and TO date and then filter the report according to the dates selected. This can be helpful when you need to base a report on a different time period each time.

In this example we are using Crystal Reports 2008 (version 12), however the same process should work with other versions of the Crystal Reports application.

The database field containing the dates will be ‘Application_Received_Date’.

 

  1. Open the report in Crystal Reports
  2. Using the Field Explorer, right-click on ‘Parameter Fields’ and select ‘New’
  3. Crystal2008-PromptReportDate1
  4. Under ‘Name’ enter DateFrom
  5. Under ‘Type’ select ‘Date’
  6. Under ‘Value Options’ –
    1. Under ‘Show on (Viewer) Panel’ change to ‘Do not show’
    2. Under ‘Prompt Text’ enter Please specify the START DATE
  7. Crystal2008-PromptReportDate2
  8. Click ‘OK’ to save the changes
  9. Again, using the Field Explorer, right-click on ‘Parameter Fields’ and select ‘New’
  10. Crystal2008-PromptReportDate1
  11. Under ‘Name’ enter DateTo
  12. Under ‘Type’ select ‘Date’
  13. Under ‘Value Options’ –
    1. Under ‘Show on (Viewer) Panel’ change to ‘Do not show’
    2. Under ‘Prompt Text’ enter Please specify the END DATE
  14. Crystal2008-PromptReportDate3
  15. Click ‘OK’ to save the changes
  16. Open the ‘Report’ menu then select ‘Select Expert’ followed by ‘Record’
  17. Crystal2008-PromptReportDate4
  18. If this is your first time using the Select Export for this report you will see the ‘Choose Field’ window. If this happens, select the field you are going to filter by and then click ‘OK’
  19. If you have already used the Select Export for this report, click on the ‘<New>’ tab. The ‘Choose Field’ window will open. Select the field you are going to filter by and click ‘OK’
  20. Crystal2008-PromptReportDate5
  21. Using the drop down list, select ‘formula:’
  22. In the text box to the right enter in the following formula (replacing databaseTable.databaseField with your filter field)
  23. {databaseTable.databaseField} =({?DateFrom} to {?DateTo})
  24. Crystal2008-PromptReportDate6
  25. Click ‘OK’ to save the changes
  26. Your report is now ready to filter by a data prompt.
  27. When you refresh the report you will be prompted for the START DATE and END DATE. The selected dates will be used to filter the report.
  28. Crystal2008-PromptReportDate7