Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting NULL dates and showing empty string in SSRS

I'm trying to format some cells in a Reporting Services report that will contain DateTime? values - or not.

If the underlying data has a NULL for that DateTime?, I'd like to show nothing (empty cell) - and if that data source contains a value, I'd like to show the date in short date format (dd.MM.yyyy in my locale).

So I tried to put this formula into the relevant SSRS cells

=FormatDateTime(Fields!DatumBSE.Value, 2)

but now I'm getting 01.01.0001 for all NULL dates....

I can't seem to wrap my head around how to do this in a SSRS (VB) formula.... I tried using IsNothing() but that doesn't seems to really help - I can detect a NULL, but how to I tell the cell to show an empty string in that case?

Solution:

I ended up using this function:

=IIF(IsNothing(Fields!DatumBSE.Value), "", FormatDateTime(Fields!DatumBSE.Value, 2))

Seems to work just fine for me now.

like image 936
marc_s Avatar asked Jan 30 '13 14:01

marc_s


People also ask

How do you handle NULL values in SSRS expression?

If we are getting the data from a Database, we can use ISNull or COALESCE function to replace Null values with values we would like. But if we want to replace the Null/Blank values in SSRS Report, we need to use IIF and Isnothing functions in expressions.

How do you display blanks as zeros in a SSRS report?

You can use FORMAT function to format numbers, e.g. =Format(Fields! MyField. Value,"0.00").

Can parameters accept NULL values in SSRS?

In SSRS a multi-value parameter cannot include a NULL value, so users can't filter the data for NULL values.

How do you check if a value is NULL in SSRS?

How to check if a parameter is NULL in SSRS? The IsNothing() function returns True if the Paramter value is NULL , otherwise it will return FALSE.


1 Answers

I just tested the following expression and it replaced the null date with an empty string:

=IIF(Fields!DatumBSE.Value is nothing, nothing, FormatDateTime(Fields!DatumBSE.Value, 2))

The other suggestion that I would make is that you could format the date to the correct format in the report dataset by placing a CASE expression around the date value.

like image 114
Taryn Avatar answered Oct 15 '22 22:10

Taryn