Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL select statement

Status
Not open for further replies.

zsyed

MIS
Dec 25, 2011
73
CA
How to write select statement to accept user input for start date and end date?

Thanks,
Zsyed
 
Are you writing the SQL as a command in Crystal? Or are you joining tables in Crystal and want to filter on user entered values for start and end dates?

If you're using tables, just create two parameters in the Field Explorer - one for start date and the other for end date. Then go to the Select Expert, select the date field you want to filter on, then select "Between", and finally select the {?Start Date} and {?End Date} parameters that you created.

If you're entering a SQL select statement in a command, do the following.

1. DO NOT create the parameters in the main report!!!! If you have already, delete them!
2. Open the Command Editor.
3. Create your Start Date and End Date parameters in the Command Editor.
4. Place your cursor in the query at the place where you want the Start Date parameter to be used then double-click on the Start Date parameter you just created. Do the same for the End Date.
5. Close the Command Editor. Crystal will ask you for values for the parameters so that it can validate the data. Enter them and click on OK.

NOTE: If you create a parameter in the Command Editor and do not use it, it will not be saved!

Parameters that are created in the Command Editor have a slightly different internal structure than those created in the report. The Command Editor parameters can be used elsewhere in the report, but the report-based parameters cannot be used in a command.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top