MS Access / forcing a date range 2 months back, bound to this week -
i have query need, date criteria, week ending 2 months prior.
so example if ran query on monday (as of right now, last monday 2/1/2016), @ 11/29/2015 through 12/5/2015 inclusive (sunday through saturday).
and next week if ran it, focus on 12/6/2015 through 12/12/2015 (sunday through saturday).
however need return exact same date range no matter weekday of week run it. example date range 11/29/2015 through 12/5/2015 selected if ran on 2/1/2016 through 2/5/2016 (mon-fri).
i'm not sure best way go this. i've considered somehow trying find next saturday , clocking few weeks, there doesn't seem week option in dateadd().
to first weekday of week sunday saturday:
firstweekdate = dateadd("d", 1 - weekday(date()), date())
to go back, 8 weeks:
eightweeksback = dateadd("ww", -8, firstweekdate)
then can add/subtrack days intervals, example.
eightweeksbacklast = dateadd("d", 6, dateadd("ww", -8, firstweekdate))
Comments
Post a Comment