user3294748
user3294748

Reputation: 27

SSRS date from previous year but with the same weekday name selected

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

Answers (1)

kyzen
kyzen

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

Related Questions