Query for "last 5 quarters"

A

ageis

I am fairly new to Access...I'm having trouble creating a query that
pulls data from the last 5 quarters (January begins the first quarter,
so it is basically 1 full year plus 3 months).

Thanks in advance!
Aaron
 
A

Allen Browne

This quarter is:
DatePart("q", Date())

So the start of this quarter is:
DateSerial(Year(Date()), 3 * (DatePart("q", Date()) - 1) + 1, 1)

So the starting date for 5 quarters ago is:
DateAdd("q", -5, DateSerial(Year(Date()), 3 * (DatePart("q", Date()) -
1) + 1, 1))
 
A

ageis

Allen,

Thank you for your fast reply. The column that I'm inputting this
criteria into is a (short)date field. Does this column need defined
differently? The query you provided me with doesn't give me any
errors, but it doesn't give me any results either.

Thanks again for your help. This is the last query that I have to
input into my project and it is just driving me nuts.

Take care,
Aaron
 
A

Allen Browne

That expression is the beginning of the period.

If you are using it in the Criteria of your query, add > before the
expression.

To test that the expression itself is giving the correct starting date, open
the Immediate Window (Ctrl+G), and enter ? followed by the expression.

The date fomat of the field does not matter, but I presume it is a Date/Time
field (not a Text field.)
 
A

ageis

Allen,

Thank you so much. The novice that I am, I tend to forget that type of
thing. It works like a charm and you totally rock.

Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top