Reputation: 11393
I face the following problem with my report for Datetime field:
#Error
I check for null or empty but i always get this error
I try this :
=IIf(CDate(Fields!recommendationDate.Value)=CDate("1/1/0001"),Nothing,
CDate(Fields!recommendationDate.Value).ToShortDateString())
=IIf(FormatDateTime(Fields!recommendationDate.Value,2)=CDate("1/1/0001"),"",FormatDateTime(Fields!recommendationDate.Value.Value,2))
=IIF(Fields!recommendationDate.Value is nothing, nothing,Format(CDate(Fields!recommendationDate.Value),"dd/MM/yyyy"))
Upvotes: 1
Views: 7553
Reputation: 11393
=IIF(CDATE(IIF(TRIM(Fields!recommendationDate.Value).ToString().Length = 0,
"1/1/0001",
Fields!recommendationDate.Value)).ToString() = CDATE("01/01/0001"),
"",
Format(CDATE(IIF(TRIM(Fields!recommendationDate.Value).ToString().Length = 0,
"1/1/0001",
Fields!recommendationDate.Value)), "dd-MMM-yyyy"))
Upvotes: 2
Reputation: 5104
The correct code would be:
IIf(IsNothing(Fields!recommendationDate.Value), "",
format(Fields!recommendationDate.Value, "dd/MM/yyyy"))
Upvotes: 6
Reputation:
I don't know if the IIf
here is similar or the same as IIf
in Ms Access, but all parts of the expression are executed (condition, true part and false part) irrespective of the outcome. You might want to try testing the field for NULL
first using something like IsNull()
:
IIf(IsNull(Fields!recommendationDate.Value), CDate('01/01/0001'), Fields!recommendationDate.Value)
Upvotes: 0