Add Leading Zeroes

Comments

6 comments

  • Adrien BLAISE

    Save a calc field to string format, enter something like:

     

    //@Unique ID

    "TEMP"

    Save.

    Then use:

    "0" + @Number field

    That should do.

    0
    Comment actions Permalink
  • Adrien BLAISE

    Sorry, I understand you need a number format, that (above) won't work.

    0
    Comment actions Permalink
  • Adrien BLAISE

    Well, no since you you're using String.

    So this should work:

    var number = @Number

    number < 10 ? "0" + number.toString() : number.toString()

    0
    Comment actions Permalink
  • Brian Hage

    This is great...Thank you!!!

    0
    Comment actions Permalink
  • Rainer Grabowski

    If I need leading zeros I use

    ("00" + number).substr(-2)
    result: 01,02 ... 11,12,100

    or

    .substr(-3)
    result: 001,011,100


    0
    Comment actions Permalink
  • Andrew Wardle

    Like it Rainer G, thanks

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk