# Make a number Formated from a unformated number

This topic is 2284 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

So I'm confused on a calculation , I'm not sure if I should use a substitute calculation for what I'm trying to do or how to use that calculation by formatting a unformatted number;

Example Unformatted Number 21100

Example Formatted Number 02-1100

So I need to add a "0" in front of the number and then always separate the first two numbers with a "-" the numbers be hide the "-" could be 1 or 20 numbers

Ideas?

##### Share on other sites

"0" & Left ( Table::number ; 1 ) & "-" & Right ( Table::number ; Length ( Table::number ) - 1 )

##### Share on other sites

1 hour ago, WSaxton said:

Example Unformatted Number 21100

The example is ambiguous - it would be preferable to state a rule first, then give examples. For example, will the given number always have exactly 5 digits? If not, what is the expected answer in each case?

---

If I am guessing correctly, you want to do:

`SerialIncrement ( "00" ; Div ( Number ; 10000 ) ) & SerialIncrement ( "-0000" ; Mod ( Number ; 10000 ) )  `

which would format:

1 as "00-0001";
12 as "00-0012";
123 as "00-0123";
1234 as "00-1234";
12345 as "01-2345";
123456 as "12-3456";
1234567 as "123-4567".

Edited by comment
##### Share on other sites

And if there is always a dash (in the middle) then it truly is not a number so the result calculation should be text.

In fact, I would ask the purpose of this number?  Is it from an export from external source?  I ask because it might be best to auto-enter the correct format to begin with or use OnObjectValidate to assist/force the User in formatting it.

Edited by LaRetta
##### Share on other sites

This topic is 2284 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account