Query Dates in the same month

mwieting85

Registered User.
Local time
Today, 11:47
Joined
Apr 13, 2017
Messages
13
I have two columns with dates in both of them. What I want to do is run a query that only shows records that have the contain the 2 months dates which are from different months. In other words filter out 2 dates that are from the same month.
 
Just to clarify...
Lets call the 2 fields DateA & DateB
If a record has DateA <>DAteB, the query should show the record
But if DateA=DatB, the record isn't selected.

If I'm correct about this being what you want, in the query design view you need to add a column Month([DateA]) & in the criteria for that column put <>Month([DateB]).
The column does not need to be visible in the query results
 
only shows records that have the contain the 2 months dates which are from different months
to be clear, because it makes a difference. Do you mean just months or do you mean year and month? i.e. you would want to filter out 12/1/2017 and 12/1/2016 because they are the same month? or you would want to include because they are the same month, but different years.
 
so you need to modify the code suggested by ridders to be

Month([DateA])<>Month([DateB]) AND Year([DateA])<>Year([DateB])
 
Just add these 2 columns to your query design as in screenshot replacing [DateA] & [DateB] with the date field names for your database
 

Attachments

  • querycriteria.PNG
    querycriteria.PNG
    4 KB · Views: 111
OK - either upload a stripped down version of your database with the table(s) & query or ...
1. Do a screenshot of your table showing some example records
2. Open your query in SQL view then copy & paste the SQL shown
 
To do so, click the Go Advanced button below where you type your message
 
FYI, you've sent the locking file, not the .accdb
 
so i just have to type in a bunch of messages till i hit a certain number
 
If someone is willing to give me an email address i can share the file out with google drive.
 
why is there such a stupid limitation with everything on this site.
 
the limitation is there to help prevent misuse of the site.
as I explained earlier, new users can still upload zip files.

as far as I am concerned, you have misused the site with pointless messages so I will leave you to sort out the problem for yourself
 

Users who are viewing this thread

Back
Top Bottom