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

Defaults for Date Parameters?

Status
Not open for further replies.

Yerdon

Programmer
Jul 29, 2002
62
US
Hi Everyone,

I have created some reports in Crystal XI. One of these reports has some data parameters which I want the user to input, like this:

Start Date: 2007-03-20
End Date: 2007-03-26

By default, I want it always to run for the past week, while allowing the user to change it if they want. However, I can't seem to figure out how to dynamically populate the fields with default values.

I can set static values, but that doesn't help as I would have to update it every week...

Any help?

Thanks!

Joseph
 
I think you have to set up a default date for each parameter like date(9999,9,9) and instruct the user in the prompt text, that to run the report for the past week, they should select 9999-09-09, and otherwise select the desired dates. Then set up the selection formula like this:

(
if {?start} <> date(9999,9,9) then
{table.date} >= {?start} else
if {?start} = date(9999,9,9) then
{table.date} >= currentdate-6
) and
(
if {?end} <> date(9999,9,9) then
{table.date} <= {?end} else
if {?start} = date(9999,9,9) then
{table.date} <= currentdate
)

-LB
 
Have you assessed whether 'lastfullweek' would fill the bill? I don't know whether this might help ...
I have several Crystal XI reports where I use 'lastfullmonth' and a default begin date parameter value of 2020-01-01. In the report I check whether the begin date is later than currentdatetime and if so I use the 'lastfullmonth' function otherwise I use the input dates.
 
What I do (and I think this is may be the same process as lbass is suggesting) is to create a Start Date parameter and an End Date parameter; the Start Date has a default value of LFM Start (Last Full Month - you could use LFW) and the End Date has a default value of LFM End. In the report filter, the code is

If{?Start Date}="LFM Start" and {?End Date}="LFM End" then {date_field} in LastFullMonth else {date_field} in {?Start Date} to {?End Date}

Now you can schedule to run automatically for LastFullMonth or run it adhoc with a selected date range.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top