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

Formula for startdate prompt

Status
Not open for further replies.

PPetronas

Programmer
Nov 13, 2008
14
0
0
US
Hi,

My report has a Startdate prompt which lets you select 'M' - last month or you can enter any date as a parameter.
based on what is selected in the prompt I need to display the last month.
If the report is run today choosing 'M' it should show Oct date.
if you enter a value in the prompt like 9/10/2008 then it should show Aug date.
I have to write a formula to get it.

If {?StartDate} = 'M' then
MonthName(month(DateAdd ('M', -1,CurrentDate)),True) & "-" & cstr(DateAdd ('M', -1,CurrentDate),"yyyy")
else
{?StartDate} (which is a string. Here I don't know how to manipulate {?StartDate} to make it point to last point last month, in this case Aug 2008)

Any ideas?

Thanks,
Petronas

 
Hi,
Convert the string to a date ( the Date('string') function)and use date math ( or just parse put the month using the Instr and Left operators, convert it to a number and reformat the date with that number - 1 as the Month for the new date)



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top