Reputation: 27
I am trying to get last year's date but with the same week day as the one selected. Meaning that if the user selects Dec 5th 2013 which is a Thursday, the formula would select Dec 6th 2012 which is also a Thursday. Any help would be greatly appreciated.
Upvotes: 0
Views: 843
Reputation: 1609
Find/Replace "Today()" with the name of the field or parameter.
=Switch (
WeekDay(Today())-WeekDay(DateAdd("d",-365,Today())) = 0, DateAdd("d",-365,Today()),
WeekDay(Today()) > WeekDay(DateAdd("d",-365,Today())), DateAdd("d",(-365)+ABS(WeekDay(Today())-WeekDay(DateAdd("d",-365,Today()))),Today()),
WeekDay(Today()) < WeekDay(DateAdd("d",-365,Today())), DateAdd("d",(-365)-ABS(WeekDay(Today())-WeekDay(DateAdd("d",-365,Today()))),Today())
)
Upvotes: 1