Hey, I have a report parameter which looks like this: 01.01.2009 00:00:00
Its a date (as string), as you might have guessed :). The problem is, this param can be an empty string as well. So I tried those expressions:
- =IIf(IsDate(Parameters!DateTo.Value), CDate(Parameters!DateTo.Value), “”)
- =IIf(Len(Parameters!DateTo.Value) > 0, CDate(Parameters!DateTo.Value), “”)
Both dont work and the value for the textfield where I print the expressions result is always #Error. As soon as I remove the CDate stuff, it works, but I have to use it. IS there another way to achieve that? What I want is to display nothing if its not a date or the date (format dd.mm.yyyy) if its a date.
Ideas?
Thanks 🙂
All arguments to the
IIfare evaluated, which results in your error, since the CDate will fail for an empty string.You can get around this by just writting a function along these lines, using a standard if statement:
Then call it with:
=Code.FormatDate(Parameters!DateTo.Value)