How can i only display only the first 4 numbers of a datainput?

Hello,

I have a input filed that is number and users can input thier birthdate + thier special numbers linked to their birth.

Example: 199801231111

How can i only display the “1998” in a text filed? (all inputs will be the same leght)

use :truncated to 4

Screenshot 2023-03-13 at 14.42.01

I dont seem to have :turncated to 4 as an option?

Select the :formatted as operator (you can leave it as a number) and then you will be able to select the :truncated to operator after that. Once you select the :truncated to operator, you will manually enter the number of characters you want.

1 Like

Yep, as Mike says it needs to be a text, so convert it to a text using the Formatted as expression…

Having said that, I’m not sure why that field needs to be a number in the first place…

I thought it would make it more simple later on if i wanted to calculate the age etc, maybe just change it to be text?

Fair enough… if there’s a reason for it to be a number then keep it as a number.

It’s easy enough to convert numbers to texts, and vice-versa, whenever you need to anyway.

Although saying that, the only way to calculate the age from that ‘number’ would be first to convert it to a text, truncate it to 4 characters, convert that text back into a number, and then use than number to calculate their age.

It might be simpler to store the ‘year’ as a separate Number field.

Yes haha, i don’t really know how to go about doing this. Maybe store birthday as a calender date? And make the last 4 digits a separate filed?

This topic was automatically closed after 70 days. New replies are no longer allowed.