Display quarterly data - "rolling" quarter

User would like to see 3 months of data at a time. For example, today is 4/26/06. He would like to see all of February, March and April (to-date). When May rolls around, February will drop off and he would like to see March, April and May (to-date). Any ideas on how to accomplish this in a query? There is a field in the query called Close Date that I will use and need to add the search criteria to that.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

For 2/1/06 to 4/26/06:

SELECT * FROM YourTable WHERE CloseDate BETWEEN CDate(Month(Date())-2 & "/1/" & Year(Date())) AND Date()

For 2/26/06 to 4/26/06:

SELECT * FROM YourTable WHERE CloseDate BETWEEN DateAdd("m", -2, Date()) AND Date()
khawkins96Author Commented:
JohnK813, thank you for responding.

4/26/06 was just the example. I need it to be able to take today's date, Now(), and find the three months from there. Also, I would prefer not to have to "hard code" this. Is there another way of doing it?

Sorry, guess I was a little misleading.  What I was trying to say was that my first statement started at the 1st of the month two months ago, and my second statement started exactly 2 months ago.

Neither is "hard coded," though.  Date() is esentially the same as Now().  The only difference is that Date() just returns the current date, whereas Now() also returns the time.  So, if you replace Date() with Now() you should be set.

Some more explanation:

CDate(Month(Date())-2 & "/1/" & Year(Date()))
Month(Date())-2 takes the month of the current date and subtracts 2
Year(Date()) gets the year of the current date
CDate converts the month + /1/ (the day) + the year into date format

DateAdd("m", -2, Date())
Subtract two months (or, if you prefer, "add -2 months") to the current date.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
khawkins96Author Commented:
Thanks for your help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.