query same day of week of previous year

  • Thread starter Thread starter Gregorio
  • Start date Start date
G

Gregorio

Access 2000 SP3
Win XP Pro
I have a SELECT query that finds a value based on a date. I'd like to find
the same weekday's value for the previous year - so not the same date but
the closest same weekday to it. Is there a VBA function or an access sql
function that makes this easy? I can code it manually, but it seems an
avoidable chore.

Thanks in advance. - G
 
Perhaps, this may work for you. Subtract one year, subtract the weekdays from
the new date to get Saturday, now add the weekday of the current date back in to
get the same day of the week.

DateAdd("yyyy",-1,YourDate)
- Weekday(DateAdd("yyyy",-1,YourDate))
+ WeekDay(YourDate)
 
Thank you, this should do the trick.

John Spencer (MVP) said:
Perhaps, this may work for you. Subtract one year, subtract the weekdays
from
the new date to get Saturday, now add the weekday of the current date back
in to
get the same day of the week.

DateAdd("yyyy",-1,YourDate)
- Weekday(DateAdd("yyyy",-1,YourDate))
+ WeekDay(YourDate)
 
Back
Top