Convert string to number

Hi
How can I do to convert value and date string to number in n8n?

I’m receive like this in my google sheets: '49850, I wanto to transform to this: 498,50

I’m receive like this in my google sheets: '07/10/2021 12:00:52, I wanto to transform to this: 07/10/2021 12:00:52

Hi @Frank_da_Silva_Costa,

To convert a string to a number you would want to use the parseInt() function, You should be able to use this in an expression so it would be something like {{parseInt($json["myString"])}}

If you wanted the number to be split with a comma it it just a case of adding .toLocaleString() so you would have {{parseInt($json["myString"]).toLocaleString()}} but as this contains a comma it would no longer be considered an int and would be a string.

The example below shows both of these options in a function node so you can get a feel for what they do.

With the second part of your question the 2 dates look to be the same so I am not sure what it is you want to do with them but for date conversions there is a handy Date & Time node which is well documented and can deal with that sort of thing.

6 Likes

Tnk you very munch

Something like this?

{{parseInt($node[“Webhook”].json[“body”][“trans_value”])}}

That would do it if the value existed.

Hi Jon, tnks for you patience with me

Ai already do it, but when append in the sheets still appear with " ’ "

Do you know if is there other way to remove this " ’ " ? and the field come as numer


image

1 Like

Does anyone know how to consume an order api to place the orders in the monday and in the subelement to place the order items