Querying Dates

  • Thread starter Thread starter Andrew Thorpe
  • Start date Start date
A

Andrew Thorpe

Can anyone give me a query statement for

1: The current quarter

2: The last quarter.

The knowledge base (Q210604) gives the answer for the
first day of the current quarter, but I'm trying to find
a statement that covers the whole period.

Andrew.
 
DatePart() can parse the quarter. DateSerial() can build the date.

Current quarter is:
Between
DateSerial(Year(Date), 3 * (DatePart("q", Date) - 1) + 1, 1)
And
DateAdd("m", 3,DateSerial(Year(Date), 3 * (DatePart("q", Date) - 1) + 1,
1)) - 1

Previous quarter is:
Between
DateAdd("m", -3, DateSerial(Year(Date), 3 * (DatePart("q", Date) - 1)+1, 1))
And
DateSerial(Year(Date), 3 * (DatePart("q", Date) - 1)+1, 1) - 1
 
Back
Top