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

Defaulting the date parameter to be today - 7days

Status
Not open for further replies.

mbryantuk

Programmer
Aug 3, 2007
29
GB
Hi

Is it possible to set the default value of a parameter to be a formula so i can default the date to be today minus 7 days?

Thanks

Matt
 
As far as im aware you cant set a formula as a default value.
The best way of doing it is to choose a value as a default and then check for that value using a formula field after. If its there make the value of the formula field 7 days ago and if the value isnt there use the value from the parameter.
Then in record selections etc use the formula field instead of the parameter.
 
To add to that, after setting a default value, e.g., 9/9/2999, you can set up your selection formula like this:

if {?date} <> date(2999,9,9) then
{table.date} = {?date} else
if {?date} = date(2999,9,9) then
{table.date} = currentdate-7

-LB
 
Ok i will give it a go,

As this is a weekly report is there any way of forcing the user to only select mondays?

Thanks

 
Do you mean for both the default and the selection? You could change the formula to:

if {?date} <> date(2999,9,9) then
{table.date} = {?date}-dayofweek({?date})+2 else
if {?date} = date(2999,9,9) then
{table.date} = currentdate-dayofweek(currentdate)+2 //current week's Monday

//or last week's Monday
{table.date} = currentdate-dayofweek(currentdate)-5

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top