How cut a cell?

HI all,
I have a string cell that look like this:27112022 (is a date DDMMYYYY), but i have to compare to another cell that look like this 271122 (DDMMYY without the 20)

In other words i have to delete the digit 5 and 6 in order to compare with a right node.
I cannot find the solution on this.

Do you have suggestion about?

Hi @gcas

I would convert both to a KNIME Dateformat using the String to Date&Time node.
Date format 27112022 => ddMMyyyy
Date format 271122 => ddMMyy
Than you can easily compare both cells.
gr. Hans

2 Likes

Thanks. Nice solutions. I should try.

But is there another node that delete specific digit in specific position, like i wrote in my first post?

Hi @gcas

I think it is possible in just one node. The String Manipulation node. Or you can take this 2 nodes solution. Split the cell by position and concate the strings together with the Column Aggregator node (no delimiter).
Schermafdruk van 2022-05-25 22-01-05
gr. Hans

3 Likes

Thanks a lot!!! it works! the solutions iā€™m looking for

2 Likes

Hi @gcas @HansS

Yes you can definitely remove the 5th and 6th digit via the String Manipulation (or Column Expressions) by joining substrings.

image

Input data:
image

Just apply this expression:


join(substr($column1$, 0, 4), substr($column1$, 6))

Results:
image

Just to explain the expression:
join(substr($column1$, 0, 4), substr($column1$, 6))

Breaking down:
substr($column1$, 0, 4) means start at the beginning (position 0), and give me the next 4 characters of $column1$, which essentially means give me the first 4 characters from $column1$. For that row, that would be ā€œ2711ā€
substr($column1$, 6) means give me everything after the 6th position of $column1$, which essentially means give me everything from the 7th position to the end of $column1$. For that row, that would be ā€œ22ā€

And joined together, you get the first 4 characters, and the 7th and 8th characters, which basically means removing the 5th and 6th characters, which for that row gave ā€œ271122ā€

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.