65
Views
4
Comments
Solved
Get Last 2 number
Question

How can i  Get Last 2 number if i have 20304050

result 50

how i can do this

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Andrew,


Imagine your number is stored on the variable InputNumber, you can get it with the following expression:



What it does: it checks if the text / number has over 2 characters / digits: if it does, it returns the last 2 digits, otherwise, it returns the text / number itself.


Kind Regards,
João

2024-05-08 06-29-37
Prince Aadil Khan Panwar

Hi Andrew Mahfouz Hanna

you can use substr function  

Substr(numbervariable,Length(numbervariable)-2,Length(numbervariable))

results 1

result 2

result 3

hope this helps

Thanks

Prince

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Andrew,

If you have a Text variable, use Substr(), like others have suggested. If you have an Integer, use Mod() like this: Mod(InputInteger, 100). It will result in the last two digits in an Integer.

2023-02-09 12-36-42
Damian Fonville

I fully agree with the solution provided by Kilian, You shouldn't convert types if not needed, in small operations this won't be visible as a performance hit, but on larger scales where every CPU cycle counts you don't want to cast between types if not needed

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.