Query for "last 5 quarters"

  • Thread starter Thread starter ageis
  • Start date Start date
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
 
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))
 
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
 
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.)
 
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
 
Back
Top