Pad A Number Field With An Exact Number Of Leading Zeros

If you have a number that needs to be padded with leading zeros, this technique does it using Formula language. The same technique (with appropriate syntax changes) can be used in most programming languages.

Padded := @Right( "00000000" + @Text(Number); 8)

This example returns an eight-character text string (stored in variable “padded” in this example). This string consists of the original value in the Number field, padded with leading zeros to a total length of 8 characters. For example, Number 123 results in Padded 00000123.

One thought on “Pad A Number Field With An Exact Number Of Leading Zeros

Comments are closed.