1
votes

I have a report (SSRS 2008 r2) and it has two parameters, @StartDate and @EndDate. Both parameters are setup as type: Date/Time and to allow NULL value. Now, the @EndDate is by default NULL (I'm handling the NULL value in the SP) and on my report I have some textboxes where I show the start and end date range that was used in the report.

For the textbox that shows the end date I use an expression that shows the current date if the parameter is null or blank but if the user selects an end date the textbox should show the selected end date. This is where I am experiencing an issue.

I'm using the following expression to show the end date.

=IIF(IsNothing(Parameters!EndDate.Value) OR Parameters!EndDate.Value = "", Format(Now(), "MMM - dd, yyyy"), Format(Parameters!EndDate.Value, "MMM - dd, yyyy"))

The expression works IF the end date parameter is NULL, but if I select an end date, the expression always returns #Error

I have created separate textboxes to try the different parts of this expression. both:

Format(Now(), "MMM - dd, yyyy")

and

Format(Parameters!EndDate.Value, "MMM - dd, yyyy")

work fine by themselves. It's when I try to put them into an IIF block to conditionally return one or the other based on if the EndDate parameter is null or blank is when it errors out.

1
This should work.. =IIF(IsNothing(Parameters!EndDate.Value) OR (NOT IsDate(Parameters!EndDate.Value)), Format(Now(), "MMM - dd, yyyy"), Format(Parameters!EndDate.Value, "MMM - dd, yyyy"))Tak

1 Answers

5
votes

This should work..

=IIF(IsNothing(Parameters!EndDate.Value) OR (NOT IsDate(Parameters!EndDate.Value)), Format(Now(), "MMM - dd, yyyy"), Format(Parameters!EndDate.Value, "MMM - dd, yyyy"))