Aldrin
Aldrin

Reputation: 766

Error in Getting month -1 when month = 1 in SSRS

I have a textbox that displays the Monthname of the month selected by the user but it's always minus 1. I am having an error when January was selected cause it should display December. So what I did is this:

=IIF(Parameters!Month.Value<>1,MonthName(Parameters!Month.Value-1),"December")

But this doesn't solved the error. Could anyone help me what I am missing here?

My parameter month value is integer (1-12)

Upvotes: 1

Views: 81

Answers (1)

Fuzzy
Fuzzy

Reputation: 3810

Your issue is this: =IIF(Parameters!Month.Value<>1,MonthName(Parameters!Month.Value-1),"December")

I'm only guessing here but I suspect it is trying to evaluate MonthName(0) When you pass it 1 and it causes and error:

What I did was this: =MonthName(IIF(Parameters!Month.Value<>1,Parameters!Month.Value-1,12),False).ToString()

And it seems to work.

This also worked: =MonthName(IIF(Parameters!Month.Value<>1,Parameters!Month.Value-1,12))

Upvotes: 1

Related Questions