Get last two charcaters of a number value

Hello, I’m trying to get the last two numbers of a value I get from a query

Eg, that is my value
image

I need to get the 08 as a number. I’ve already tried this:

It didn’t work

Slice is used for arrays. Yours is the first value in an array, hence not the array itself.

Use Sub or Sub String Between instead

Edit: see:


2 Likes

I don’t know if the sintaxis is ok, but I believe it’s not because it doesn’t work.

Hello,
Just use the SUB formatter option, it will generate the right code and files for you …

I´m getting this error:

This is the expression:

I need to extract the number as number, because afterwords I have to sum it to another number.

You will need to first convert the value to string, apply substring, then convert back to number :slight_smile:

.toString().substr(2, 2).toNumber()

Excellent! But I’ve got other problem…

Some of the codes have 4 digits, an other have 5 digits. Form all codes, i only need the last two.

For eg: if I have the number 10001 using “substr(3, 2)” extracts 01. But in 1001 extracts only 1 (and I need 01)

Then substract the last two:

substr(-2, 2)

This will always start 2 digits from the end :slight_smile:

1 Like

Very helpful! Thank you very much

1 Like