Addition "-" into data

Hi everybody,

i have data like “25012020” and “26-01-2020” (String type) in same column
I would like to change it to “25-01-2020”
What’s node i can use for it.
String Manipulate or Java Snippet or anynode?

Cheers

Hi @aabbaa,

If the format is the same for all cells, one simple way would be to use the String Manipulation node. With an expression like:

join(substr($input$, 0, 2), "-", substr($input$, 2, 2),  "-", substr($input$, 4, 4))

Where input is the name of the column containing the date values like 25012020. If the column contains both properly formatted cells with values like and “25-01-2020” and cells like “25012020”, you could use a Row Filter before the String Manipulation node, to filter out those that already have the right format (those contain a “-”). After that you could Concatenate the tables again.

I hope this goes in the right direction.

4 Likes

Hi @aabbaa,

with java snippet (simple) without Row Filter

if ($Column$.length() == 8) {return $Column$.substring(0,2) + “-” + $Column$.substring(2,4) + “-” + $Column$.substring(4,8);}
else return $Column$;

or

if ($Column$.length() == 8) {return $Column$.substring(0,2).concat("-").concat($Column$.substring(2,4)).concat("-").concat($Column$.substring(4,8));}
else return $Column$;

3 Likes

@oole’s answer is work. And @morpheus’s answer is work in 1step.
Thanks you two.

1 Like

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