SQL Statement

dsellers1

Registered User.
Local time
Today, 09:22
Joined
May 19, 2009
Messages
39
Here is a quick excerpt from a union query I am working on. I need to pull the data only for last month based off of the 'Month Reporting'. I am sure that it's a Where statement but I don't know exactly how to word it. Is it easier than what I am making it out to be?

SELECT Format([Month Reporting],"mmm yyyy") AS 'Month Reporting',[Portfolio]
From [qryTotalsUS]

Union ALL SELECT Format([Month Reporting],"mmm yyyy") AS 'Month Reporting',[Portfolio]
From [qryTotalsCAD]

UNION ALL SELECT Format([Month Reporting],"mmm yyyy") AS 'Month Reporting',[Portfolio]
From [qryTotalsPR];
 
Add a WHERE clause after the FROM clause on all those individual queries. It would look like this:

Code:
WHERE Format([Month Reporting], "mmm yyyy")=Format(DateAdd("m", -1, Date()), "mmm yyyy")

Essentially you are taking today's date, subtracting a month and formatting it to what you are currently using.
 
Worked perfectly. Thanks for the help!
 

Users who are viewing this thread

Back
Top Bottom