问题是
Iif不会短路。一种丑陋的解决方法是使用嵌套
Iif:
=IIf(Fields!MyDate.Value = Nothing, "", _ Format(CDate(Iif(Fields!MyDate.Value = Nothing, Today(),Fields!MyDate.Value)), "dd-MM-yyyy"))
这很丑陋,重复且容易出错。
另一个选择是创建一个自定义函数,该函数 会 发生短路:
Public Function FormatOrBlank (ByVal theDate As DateTime, ByVal format As String)If String.IsNullOrWhiteSpace(theDate) Return ""Else Return Format(CDate(theDate)), format)End IfEnd Function



