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

Display the previous 3 months 2

Status
Not open for further replies.

seokid

Technical User
Jun 25, 2010
2
US
I currently have a report that prompts a user for a start date and end date. I would like to change that report to automatically use the last 3 months instead of prompting for dates.

Any suggestions?
 

Your select statement would be:

{DatabaseDate} in dateadd("m", -3, currentdate) to currentdate

If you wanted last full three months you'd have to modify it slightly.

 
Just a little tweak. You might want to use "to currentdate-1" or dateadd("m",-3, currentdate+1) so that you don't include an extra day.

Note also that dateadd only subtracts the number from the month value--it's not actually calculating number of days--and if the result doesn't exist (e.g., if you subtract 3 months from 5/31/2010, there is no 2/31/2010, and the result will show the nearest possible date, e.g., 2/28/2010. So it really depends upon what you mean by "month". If it is 30 days, then use currentdate-89 to currentdate.

-LB
 
Wow! Got it to work, thank you both for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top