Query Dates in the same month (1 Viewer)

mwieting85

Registered User.
Local time
Yesterday, 19:31
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.
 

isladogs

MVP / VIP
Local time
Today, 01:31
Joined
Jan 14, 2017
Messages
18,257
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
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:31
Joined
Feb 19, 2013
Messages
16,653
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.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:31
Joined
Feb 19, 2013
Messages
16,653
so you need to modify the code suggested by ridders to be

Month([DateA])<>Month([DateB]) AND Year([DateA])<>Year([DateB])
 

isladogs

MVP / VIP
Local time
Today, 01:31
Joined
Jan 14, 2017
Messages
18,257
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: 83

isladogs

MVP / VIP
Local time
Today, 01:31
Joined
Jan 14, 2017
Messages
18,257
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
 

isladogs

MVP / VIP
Local time
Today, 01:31
Joined
Jan 14, 2017
Messages
18,257
You should be able to upload as a zip file
 

isladogs

MVP / VIP
Local time
Today, 01:31
Joined
Jan 14, 2017
Messages
18,257
To do so, click the Go Advanced button below where you type your message
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:31
Joined
Feb 19, 2013
Messages
16,653
FYI, you've sent the locking file, not the .accdb
 

mwieting85

Registered User.
Local time
Yesterday, 19:31
Joined
Apr 13, 2017
Messages
13
Okay. i have to hit 10 post to upload or include a hyperlink.
 

mwieting85

Registered User.
Local time
Yesterday, 19:31
Joined
Apr 13, 2017
Messages
13
so i just have to type in a bunch of messages till i hit a certain number
 

mwieting85

Registered User.
Local time
Yesterday, 19:31
Joined
Apr 13, 2017
Messages
13
If someone is willing to give me an email address i can share the file out with google drive.
 

mwieting85

Registered User.
Local time
Yesterday, 19:31
Joined
Apr 13, 2017
Messages
13
why is there such a stupid limitation with everything on this site.
 

isladogs

MVP / VIP
Local time
Today, 01:31
Joined
Jan 14, 2017
Messages
18,257
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

Top Bottom