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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a date problem ,please help me

Status
Not open for further replies.

alex00100

Programmer
Dec 28, 2002
3
CN
I have a report with a datetime parameter.
If user input the parameter,then the report will retrieve date as user input ,else if user havn't input date,the report will retrieve the yesterday data by default.how should i do?Thanks!!!
 
I think the parameter will have to be filled by the user. I don't think they can skip it.

But you can set the parameter's default value to a very old date (like 1/1/1950) and then have the selection formula say:

if {?param} = Date (1950,1,1)
then {Date.Field} = currentdate - 1
else {Date.Field} = {?param}
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Thanks for your response ,it's a good idea to solve my problem .
 
thnaks for your response ,but another problem occur ,if I use the control struct such as "if then else" is selection expert,then the selection will not be push to database server, so database base server will return all the result ,it is terrible ,if so ,the perfromance is very low.How can I solve the problem?Thanks in advance!
 
Hi

Instead of using the report parameter, write a query and pass this report parameter as parameter to the query. Create a report based on this query.

Regards
Krishna Kumar
 
You might try using the Switch function instead of an if/then/else.

I like Ken's approach because of its simplicity

{Date.Field} in switch
( {?Parm} = Date (1950,1,1) , currentdate - 1 ,
true,{?Parm})

The only potential problem here is that the ?parm must be in a date format.

I believe this gets pushed down to the server


Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top