IIF with dateformatting gives #error even though formatting shouldnt be run

  • Im creating a generic list report. For each column X i check if its DataType = 5, then i format to shortdate all those values.

    This works when datatype is 5 and dates come out fine. When tits not 5 , thus just string value like Name, I get #Error.

    It looks like it evaluates both IIF outcomes and during that it "crashes". What Can I do? Or what am I doing wrong?

    =IIf(First(Fields!ColumnDataTypeX.Value, "ColumnQuery") = 5, FormatDateTime(Fields!ColumnX.Value, DateFormat.ShortDate), Fields!ColumnX.Value)

    Thanks in advance

  • It's a known flaw in the IIF evaluation. Check out this page as a suggested work around, there are others on the web.

    Steve.

  • Thanks for the help 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply