SSRS Display question mark when date is blank

Applies to:
  • Microsoft SQL Server Reporting Services 2012
  • Microsoft Visual Studio 2012 Premium
  • Microsoft Windows 7 Enterprise

What?
So I have a column in an SSRS report which displays a date. Being rather pernickety, I would like a question mark to display if there is no date to populate the field.

Why?
At the moment, the expression in there is something like this:
=Format(Fields!MyCompletionTime.Value, "dd/MM/yyyy HH:mm:ss")
-- yields 11/02/2014 11:21:32
Sounds good, where's the problem?

The problem
Putting the date in an IIF (if-then-else) statement displays "#Error". You should get errors referring to converting strings to dates and incorrect data types.

How?
The fix is to simply get the field and both results to be of the same data type:
=IIF(CStr(Fields!MyCompletionTime.Value)<>"", Cstr(Fields!MyCompletionTime.Value), "?")

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.