Display blank value (“”) as date in SSRS

旧巷老猫 提交于 2019-12-06 05:25:37

Your issue is that SSRS IIf expressions do not short circuit, so whenever you have a blank string your code will still be trying the FormatDateTime conversion, so you get this error even with your check.

You can add some logic to stop the empty string being evaluated in the FormatDateTime expression by using another IIf to change it to a NULL value, which won't fail:

=IIF(Fields!DiscontinuedDate.Value = ""
    , ""
    , FormatDateTime(IIf(Fields!DiscontinuedDate.Value = ""
            , Nothing
            , Fields!DiscontinuedDate.Value)
        , DateFormat.ShortDate))

That solves your immediate issue, but assuming the underlying data is text based, I would also recommend looking at your underlying data and using explicit DateTime type data types instead of strings to prevent these at the lowest possible level.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!