Using LIKE function

  • Hi,

     

    I have the following peice of code that has been working well for me for a long time. You will see below that  (Not Submitted) is appended to the Description.Value based on the IIF statement. It works great!

    =IIF( Fields!Date_Received.Value < "01/01/00" AND Fields!Exam_Date.Value > "01/01/00" AND   NOW() > DATEADD("d",8,Fields!Date.Value) AND Fields!Mark.Value = -1, Fields!Description.Value  & "  (Not submitted)", IIf( Fields!Absent.Value  = 1 , Fields!Description.Value & "     (Absent)", Fields!Description.Value ) )

    However, a requirement has now arisen that the (Not Submitted) only be appended to the Description.Value if the Description.Value does not contain the word 'Real'....I attempted the code below so far by adding to the beginning of the IIF statement..

    =IIF(Fields!Description.Value NOT LIKE "%Real%"  AND Fields!Date_Received.Value < "01/01/00" AND Fields!Exam_Date.Value > "01/01/00" AND   NOW() > DATEADD("d",8,Fields!Date.Value) AND Fields!Mark.Value = -1, Fields!Description.Value  & "  (Not submitted)", IIf( Fields!Absent.Value  = 1 , Fields!Description.Value & "     (Absent)", Fields!Description.Value ) )

    =IIF(Fields!Description.Value <> "%Real%"  AND Fields!Date_Received.Value < "01/01/00" AND Fields!Exam_Date.Value > "01/01/00" AND   NOW() > DATEADD("d",8,Fields!Date.Value) AND Fields!Mark.Value = -1, Fields!Description.Value  & "  (Not submitted)", IIf( Fields!Absent.Value  = 1 , Fields!Description.Value & "     (Absent)", Fields!Description.Value ) )

    Both have failed so far....

    Is there a better way to code this?

     

    Thanks

  • Try this instead (changes in BOLD):

     

    select

    IIF( Fields!Date_Received.Value < '01/01/00'

    AND Fields!Exam_Date.Value > "01/01/00"

    AND NOW() > DATEADD("d",8,Fields!Date.Value)

    AND Fields!Mark.Value = -1,

    Fields

    !Description.Value & IIF( InStr(Fields!Description.Value, 'Real') > 0, " (Not submitted)", "" )

    , Fields!Description.Value & IIf( Fields!Absent.Value = 1 , " (Absent)", "" ) )

  • Hi Paul,

    The changes do not appeared to have worked. Although I get no compilation errors when previewing the report now the field is just populated with the expression, which is a little odd.

    Any ideas?

    Cheers

  • Hi David, please change the 'SELECT' keyword at the beginning to the equal sign '='. My apologies if the code I posted was not compatible for RS.

    Paul

  • I did try this a little earlier but still didn't have any luck.

    Is it possible to use something like NOT LIKE "*Real*" in an expression?

    Thanks

  • Try this instead:

    IIF( Fields!Date_Received.Value < "01/01/00"

    AND Fields!Exam_Date.Value > "01/01/00"

    AND NOW() > DATEADD("d",8,Fields!Date.Value)

    AND Fields!Mark.Value = -1,

    Fields!Description.Value & IIF( InStr(Fields!Description.Value, "Real") > 0, "", " (Not submitted)" )

    , Fields!Description.Value & IIf( Fields!Absent.Value = 1, " (Absent)", "" ) )

  • That looks to be working correctly!

    Thank you for your help it is much appreciated.

     

Viewing 7 posts - 1 through 6 (of 6 total)

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