IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#45925 - 12/18/13 02:05 PM Padding a field with leading zeros
tingarra Offline
OL Newbie

Registered: 10/13/11
Posts: 8
Hi,

Is it possible to add leading zeros to a data field?

I have a list that the customer wants the record's ID number to be 12 digits, and if it's not to ad the correct number of zeros to the beginning to make it so.

So if the record is 1234, they want it to say 000000001234, etc.

Is there any way to do that in an expression? I really do not want to have to go through 3000 records by hand and add them in.

Thanks in advance!

Top
#45937 - 12/19/13 01:55 PM Re: Padding a field with leading zeros [Re: tingarra]
Benoit Potvin
Unregistered


Hi,

Here's how you could do it:

1. In the Variables window, right click and add one variable, let's call it myVar

2. In the expression editor for this variable, write the following expression:

RIGHT("0000000000" & [MyDataField], 10)

where:

"0000000000" is what we want to pad our field with. Here, we've decided to pad with up to 10 zeroes.

[MyDataField] is your data field.

10 is the number of rightmost characters the RIGHT expression will keep.

3. Use @MyVar@ to display the padded value of MyDataField


Hope this helps!

Top