90 Days, but not current month

JordanR

Registered User.
Local time
Today, 10:49
Joined
Jan 25, 2005
Messages
72
I have a query setup:
Code:
SELECT Format([RepDate],"mmmm yyyy") AS [Date Reported],
inc_Incident.Category, Count(inc_Incident.Category) 
AS CountOfCategory
FROM inc_Incident
GROUP BY Format([RepDate],"mmmm yyyy"), inc_Incident.Category, 
inc_Incident.Status
HAVING (((inc_Incident.Status)<>"Cancelled"));

I'm trying to figure out the best way to get the query to return category counts per month (formatted MMMM YYYY) for only the last 3 full months (not including the current month).
If it matters Repdate is formated Long Date.

Any help people can offer?
 
WHERE (((Month([repdate])) Between Month(Date())-3 And Month(Date())-1))

will select the required records

Brian
 
Thanks for the help, everyone. But I am getting a syntax error. Here's what I have
Code:
SELECT Format([RepDate],"mmmm yyyy") AS [Date Reported], 
inc_Incident.Category, Count(inc_Incident.Category) AS CountOfCategory
FROM inc_Incident
GROUP BY Format([RepDate],"mmmm yyyy"), inc_Incident.Category, 
inc_Incident.Status
HAVING (((inc_Incident.Status)<>"Cancelled")) AND WHERE [RepDate] 
Between DateSerial(Year(DateAdd("m", -4, Date())), Month(DateAdd("m", -4, 
Date())), 1) And DateSerial(Year(InDate), Month(InDate), 0);

I'm getting Syntax Error (missing operator) in query expression '(((inc_Incident.Status)<>"Cancelled")) AND WHERE [RepDate] Between DateSerial(Year(DateAdd("m", -4, Date())), Month(DateAdd("m", -4, Date())), 1) And DateSerial(Year(InDate), Month(InDate), 0);'
 
Thanks so much, Pat. The reason I don't have Status in the SELECT is because I need that condition, but I don't want the results displayed. There a better way to do that?

Also, I just tried it and it seems to calculate the date like a champ, but I'm not getting unique counts for the month.
I'm getting:
Code:
August 2005   Category 3   1
August 2005   Category 3   4

Instead of one line that reads
Code:
August 2005   Category 3   5

Thoughts?
 
Last edited:
Yea, man. I think I got it. Thanks so much for the help.
 

Users who are viewing this thread

Back
Top Bottom