Exclude current month data

anishkgt

Registered User.
Local time
Today, 14:24
Joined
Nov 4, 2013
Messages
384
I have a query that shows data from January to March (which is the current month). is there a possibility to exclude the current month

The query has the following fields

SegmentDate
PCC
AgencyName
SegmentData

Thanks in advance.
 
Last edited:
First, 'Date' is a bad field name because it makes coding queries and VB harder to write. I'd rename it by prefixing it with what the date represents (i.e. AgencyDate, PCC_Date, etc.).

For your issue, you need to create a calculated field to hold a Month/Year code which you can use in your query to use as criteria:

ReportingMonthCode: Month([Date]) & "-" & Year([Date])


Then underneath that you determine the current month/year code and use that as criteria:

Month(Date()) & "-" & Year(Date())
 
thank plog, The date field name is SegmentDate. sorry about that. I did try out that criteria. what I wanted was the opposite. this criteria show data for the current month, I need to exclude current month and show all other months data.

thank for your time plog
 
oh and it shows only data of 1 march 2014 and omits all other data from jan to feb including those after 1st march 2014
 
Missed it by 2 characters, sorry. Try this for the criteria:

<>Month(Date()) & "-" & Year(Date())
 
just tried it and it did not work :( still has no effect on the data displayed
 
well I've managed to display what I need by the expression <#01-Mar-14#, but that is not I need. I need it to be automatically exclude current month.
 
sorry about that pr2.

I saw a similar thread which was similar to what I was facing. I did not understand that code also

Sorry for duplicating posts.
 
hi pr2

my fields are as follows, previously the date field was wrong

SegmentDate
PCC
AgencyName
SegmentData
 
I've also managed to get this expression to work for me >#01-Jan-14# And <#01-Mar-14#

would appreciate if you guys could replace the #01-Mar-14 with an expression to read as current month.
 
You can use something like..
Code:
SELECT theFields FROM theTable
WHERE theDateField < DateSerial(Year(Date), Month(Date), 1);
 

Users who are viewing this thread

Back
Top Bottom