1
votes

A stored procedure is included in a report builder file of type rdl. the stored procedure has many fields. One of the fields returns a date (not datetime). The desired outcome in the report is to show the date only and empty field if no date is returned.

With just the field value the result shows empty field when the date is null otherwise shows the date with a datetime value.

Using IIF to check the value for 'nothing' as shown below.

=IIF(Fields!myDate.Value Is Nothing,"",Fields!myDate.Value)

The output is the same. A datetime value is shown when date is available.

Attempting to use the shortDateString() function yields the correct result in when a date is present but #Error when a date is NOT present. This is the statement:

=IIF(Fields!rlsPromoDate.Value Is Nothing, "", 
Fields!rlsPromoDate.Value.ToShortDateString())

The version below was attempted. No errors resulted however the date was not returned but this was "Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.FieldImpl".

=IIF(Fields!myDate.Value Is Nothing,"", String.Format("{0:MM/dd/yyyy}", 
Fields!myDate))

Please advise if there is a solution.

1

1 Answers

3
votes

Try the following:

=IIF(Fields!rlsPromoDate.Value Is Nothing, "", Format(Fields!rlsPromoDate.Value, "dd/MM/yyyy"))

or whatever date format you'd actually like to use.