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

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.

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
  1.  =Format(Fields!MyCompletionTime.Value, "dd/MM/yyyy HH:mm:ss") 
  2.  -- 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.

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), "?")
  1.  =IIF(CStr(Fields!MyCompletionTime.Value)"", Cstr(Fields!MyCompletionTime.Value), "?") 
Category: SQL Server Reporting Services :: Article: 562

Credit where Credit is Due:

Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman

Related Articles

Joes Revolver Map


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:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2022 Joel Lipman .com. All Rights Reserved.