INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Formatting number with leading zeros

Formatting number with leading zeros

(OP)
I have a number 1234.56 for example, and I need the total length to be 18 characters with leading zeros. In other words, "000000000001234.56".

I currently have a formula that works by converting my number to a string using totext(), then calculating the number of leading zeros I need based of the result and then concatenating them to the front of the string. But I am thinking there is an easier way. Any insights appreciated.

Software Training, Implementation, Programming and Support for Macola Progression, Macola ES, Synergy, and Crystal Reports. Check out our Macola tools: www.gainfocus.biz/exceladdin.html

RE: Formatting number with leading zeros

totext({numberfield},"0000000000000000.00")

RE: Formatting number with leading zeros

(OP)
Many thanks. I have lost a lot of my crystal skills over the past several years.

Software Training, Implementation, Programming and Support for Macola Progression, Macola ES, Synergy, and Crystal Reports. Check out our Macola tools: www.gainfocus.biz/exceladdin.html

RE: Formatting number with leading zeros

In general,

1) if you need leading or trailing zeros, you don't have a NUMBER (although the destination user may convert your string with leading or trailing zeros to a number in their system) you have a STRING. You will not be using this value with leading and trailing zeros, to perform arithmetic.

2) if your 'number' is used as a name for something like a part or an invoice or a person or a place, your 'number,' a part number, invoice number, social security number, employee number, postal code, are 'numbers' on which no arithmetic operation would ever logically be performed. They are IDENTIFIERS and ought to be STORED and treated as STRINGS.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close