Date Filter: Between Yesterday and 365 days (1 Viewer)

tom.lockhart

New member
Joined
Feb 14, 2024
Messages
2
All,

Been a LONG time lurker and searcher but just haven't been able to find the piece today to get me over the top.

I have a date field and I'm trying to look at a range in query of Yesterday and 365 days.

Any help would be GREATLY appreciated.
 
Hi. Welcome to AWF!

Did you mean 365 days ago or 365 days into the future from yesterday?
 
Hi. Welcome to AWF!

Did you mean 365 days ago or 365 days into the future from yesterday?
Thank you for the quick answer, and I'm happy to be here, maybe I can start helping out now after lurking and fixing every problem i've had the last 3 years!

365 days ago, so the anchor date is yesterday and then 365. I know how to do this in MySQL, but working with an Access db now.

Due to leap year, if I ran the query today I would want it to show the earliest date as 2-13-2024 and the oldest as 2-15-2023.
 
SQL requires Date() as function
Code:
WHERE mydate between date()-366 and date()-1
 
Last edited:
If your dates might have time portions, then you will actually want dates less than today for yesterday's dates:
SQL:
WHERE mydate >= Date() - 366
  AND mydate < Date()
 
If you want Access to deal with leap year, then ask it to subtract one year using datediff(). If you just add/subtract a number from a date field, Access does exactly that because it assumes you know what you are doing.
 

Users who are viewing this thread

Top Bottom