Search code examples
if-statementgoogle-sheetsstring-formattinggoogle-sheets-formulanumber-formatting

Google Sheets: same values don't recognized as same


I'm trying to build an IF formula, where I compare two dates, but my formula means same dates would be different.

So, I have in A2 a date, like 2019-11-04.

In B2 I have a date like 201945.

In A3 I check the week number with =isoweeknum(A2) and get 45.

In B3 I check the week number with =MID(B2; 5; 2) and get 45 too.

Then i try to compare them with =IF(((isoweeknum(A2))=(MID(B2;5;2))); "OK"; "different numbers") - but get different numbers.

On trying to write the formula as =IF(a3=b3; "OK"; "different numbers") I get different numbers too.

Why Sheets treat it as different? How should I write the formula so, that these same values are recognized as same?


Solution

  • MID auto-converts stuff to string (Plain text) so try:

    =IF(ISOWEEKNUM(A2)=MID(B2; 5; 2)*1; "OK"; "different numbers")
    

    0