Why do the dates not match in this function?

Nigel Light
Nigel Light Contributor
edited December 2023 in General

Hi,

We are trying to write a Function that checks to see if a valus is a date and, if so, formats it (for consistency). It then does the same for the other date and compares.
Using the parameter values below it doesn't seem to recognise them as the same date and returns a false when the dates are the same, just that the format is different.

Anything we are doing wrong?

Thanks

@Nigel Light @Pete Robson

Best Answers

  • Fatme Kungyova
    Fatme Kungyova Experian Employee
    Answer ✓

    Hi @Nigel Light, when you apply the 'Format date' function to the date its type is changed to alphanumeric, which causes the check for equality to fail since it is comparing alphanumerics instead of dates.


    You can check that by adding the 'Datatype' function before and after the 'Format date' step, which will tell you what are the types of the values.

    Here is an example:

    The results are:


  • Nigel Light
    Nigel Light Contributor
    Answer ✓

    Hi

    Thanks for getting back to me - really helpful and I think we have a solution now

    Nige

  • Faz Haq
    Faz Haq Experian Employee
    Answer ✓

    Hi Nige,

    Basically Equals only looks at the alphanumeric charaters everything else ignored. If you change "Equals" to "Equals (Strict)" you will then get the expected results.

    The "Remove white space" function removes "Space", "tab", "line feed (newline)", "carriage return", "form feed", and "vertical tab".

Answers

  • Nigel Light
    Nigel Light Contributor

    Taking this 1 step further, comparing National Insurance Number fields - the results are as required (ie ignoring case and any spaces) for the following examples, other than it matches with the inclusion of dashes in the 2nd NI No value in example 6. Matching using an "equals (strict)" gives the correct results. Is this a similar case of data type?

  • Nigel Light
    Nigel Light Contributor

    Ah… I get it.
    Thanks
    Nige