# Convert 4 digit number to 5 digit number beginning with 0?

**URL:** <https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330>\
**Category:** Ignition\
**Created:** [April 20, 2012, 6:50pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330 "2012-04-20T18:50:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [April 20, 2012, 6:50pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330/1 "2012-04-20T18:50:27Z")

</div>

Trying to figure out an expression to convert numbers that are 4 digits to 5 digits beginning with 0.

Such as 1605 to 01605

While at the same time leaving 5 digit numbers alone such as 16058 as 16058

Not certain how to go about using the len or if I even need to gather the length of the number.

for i in 0{1000…9999} {10000…99999}  
???

Just wanting to:

take the value from a numeric text field box  
add a 0 to the beginning of the number if 4 digits in length to make it 5  
then have it available to be bound to another numeric text field box

Any thoughts of how this could be accomplished?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 20, 2012, 7:12pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330/2 "2012-04-20T19:12:25Z")

</div>

Set the Decimal Format Property of the Numeric Text Box to “00000”. That will force the digit. a “#” eliminates leading or trailing zeroes. No expression or script required. 😉

---

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [April 20, 2012, 7:38pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330/3 "2012-04-20T19:38:49Z")

</div>

Jordan,

Thanks much closer. I can see the number formatted correctly, but how can I get the number bound to another component with that formatting?

When I bond it to another it is formatted without the leading 0.

I tried on the component expression:

numberFormat({Root Container.Dropdown.selectedValue}, “00000”)

Ultimately I would like to be able to bond the value with the leading 0 to a custom property for a report.

Thanks  
Casey

---

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [April 20, 2012, 7:51pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330/4 "2012-04-20T19:51:27Z")

</div>

I have the value writting to a int4 memory tag with that number formatting and the value shows correctly.

When I bond that memory tag to the custom int property of the report, the formatting appears to be dropped.

---

<div class="post-metadata">

**Author:** ![markdobtech](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@markdobtech](https://forum.inductiveautomation.com/u/markdobtech)\
**Post date:** [April 23, 2012, 12:22pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330/5 "2012-04-23T12:22:30Z")

</div>

Data types. Although the value is numeric, for processing purposes you are treating it like a string. I am not sure why you are doing this, but if it is required you will need to convert to string and then bind on the converted tag.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 23, 2012, 3:05pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330/6 "2012-04-23T15:05:59Z")

</div>

[quote="cswett"]I have the value writting to a int4 memory tag with that number formatting and the value shows correctly.

When I bond that memory tag to the custom int property of the report, the formatting appears to be dropped.[/quote]

Just so I'm on the same page, you mean the reporting module, right?

> [@markdobtech](#):
>
> Data types. Although the value is numeric, for processing purposes you are treating it like a string. I am not sure why you are doing this, but if it is required you will need to convert to string and then bind on the converted tag.

That'd be a final workaround, but it should be possible to do with the format string in the report. Also, if there's any math that would have to be done to it within the report, then a string won't cut it.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 23, 2012, 3:35pm UTC](https://forum.inductiveautomation.com/t/convert-4-digit-number-to-5-digit-number-beginning-with-0/4330/7 "2012-04-23T15:35:50Z")

</div>

Since you mentioned a custom property for the report, I’m assuming the Reporting Module.

After adding a custom integer property to the report viewer:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/848e17937795ec7f7352f5d590fbdf83e4f8d961.png)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a94fd17f6ca6f378d8731774247afa57c2ed1b9c.png)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fb404d10b3592d300d023a9e62e483d8f10546b3.png)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/8e453d8564384ea7a2df908027a0b5f9cabf84a4.png)
