havmaage
havmaage

Reputation: 135

MS Report builder expression if monday then today -3 days else - one dat

I need to add a default date value to a parameter in report builder 3.0 If today is monday then extract 3 day else extract 1 day. I have made an example in vb that works

If Weekday(Now(), vbMonday) = 1 Then

        TextBox2.Text = DateAdd("d", -3, Today())
Else
        TextBox2.Text = DateAdd("d", -1, Today())
End If

Now i want to do it in report builder, i tried following

=IFF (Weekday(Now(), vbMonday) = 1,DateAdd("d", -3, Today()), IFF(Weekday(Now(), vbMonday) != 1,    DateAdd("d", -1, Today()))

I am not familiar with the syntax in report builder when using if then else. can someone give me an example.

Upvotes: 1

Views: 1586

Answers (1)

alejandro zuleta
alejandro zuleta

Reputation: 14108

Try this:

=IIF(WeekDay(Now(),VbMonday)=1,
DateAdd("d", -3, Today()),
DateAdd("d", -1, Today())
)

You are using an unnecessary nested IIF to evaluate the false part of the outer IIF.

Upvotes: 2

Related Questions