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

tom.lockhart

New member
Local time
Today, 00:05
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:05
Joined
Oct 29, 2018
Messages
21,473
Hi. Welcome to AWF!

Did you mean 365 days ago or 365 days into the future from yesterday?
 

tom.lockhart

New member
Local time
Today, 00:05
Joined
Feb 14, 2024
Messages
2
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.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 19, 2013
Messages
16,612
Try

mydate between date-366 and date-1
 

ebs17

Well-known member
Local time
Today, 09:05
Joined
Feb 7, 2020
Messages
1,946
SQL requires Date() as function
Code:
WHERE mydate between date()-366 and date()-1
 
Last edited:

cheekybuddha

AWF VIP
Local time
Today, 08:05
Joined
Jul 21, 2014
Messages
2,280
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()
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:05
Joined
Feb 19, 2002
Messages
43,275
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