Last 4 numbers for another field

I have a random number field and I want to have another field that is the last 4 numbers of my original field

I tried the following but I am guessing its for strings then Integers

newField(‘Current_Field1’)[0…4]

error: no implicit conversion of Range into Integer

What about following?

Current_Field1 % 10000

I like using % as the previous poster mentioned. You can also convert any number to a string using to_s and any string to an integer using to_i.

1 Like