Query math

  • Thread starter Thread starter Stephanie
  • Start date Start date
S

Stephanie

Hi. After lots of help from many helpful Discussion Group folks, I have:

[LoggedDate] BETWEEN [forms]![frQuick]![StartDate] AND
[[forms]![frQuick]![EndDate]
"Q" & ([LoggedMonth]+2)\3
DatePart("m",[LoggedDate])
[LoggedYear] -currently have this hard coded as 2009

Which all gives me the current quarter.

Now I would like to be able to determine the previous quarter so that I can
have a trend analysis from one quarter to the previous quarter.

I'd appreciate your suggestions.
Thanks,
Stephanie
 
Since

Datepart( "q", someDate)

returns the 'quarter' of the said date, you can GROUP BY on the computed
expression:


SELECT Year(dateTimeField), DatePart(""q", dateTimeField),
SUM(amount),
AVG(amount),
STDEV(amount)
FROM somewhere
GROUP BY Year(dateTimeField), DatePart(""q", dateTimeField)



Vanderghast, Access MVP
 
Back
Top