Thread: Date Query
View Single Post
Old 09-24-2019, 01:18 AM   #10
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,336
Thanks: 40
Thanked 3,670 Times in 3,538 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Date Query

Quote:
I have put it in the Criteria part of the Query under the 'Date assessed' section and it still coming with dates from 2019 ?

this statement brings through all records withing the last two years
Code:
WHERE (((tblUnitEquivalence.[Date Assessed])>DateAdd("yyyy",-2,Date())));
so meets your second requirement

Quote:
I have a "Date assessed" Section that is in my original table. In one of my queries I only want it to show data that is older than 2 years from today's date, and my other query I would like to show anything from 2 years ago until today's date.
to get those more than two years old the criteria needs to be

WHERE (((tblUnitEquivalence.[Date Assessed])<=DateAdd("yyyy",-2,Date())));

Note: if your date_assessed field includes dates that are later than today then these will be returned by the query for your second requirement. If this is the case then the criteria needs to be

Code:
WHERE tblUnitEquivalence.[Date Assessed]>DateAdd("yyyy",-2,Date()) AND tblUnitEquivalence.[Date Assessed]<=Date()
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote