Query math

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
 
V

vanderghast

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
 

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