Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    134

    Unanswered: Add leading Zeros to integer?

    I need to cast an integer to a string to append to another string for a barcode.

    How can I get 1 -> '0001' OR 100 -> '0100'

    Any suggestions?

    Mike B

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    As long as they are all positive numbers, you can use:
    Code:
    SELECT Replace(Str(1, 20), ' ', '0')
    If you need to cope with negative numbers, I'd recommend using a short function.... It is cleaner.

    -PatP

  3. #3
    Join Date
    Feb 2004
    Posts
    134
    Quote Originally Posted by Pat Phelan
    As long as they are all positive numbers, you can use:
    Code:
    SELECT Replace(Str(1, 20), ' ', '0')
    If you need to cope with negative numbers, I'd recommend using a short function.... It is cleaner.

    -PatP
    Thanks that was what I was looking for.

    Mike B

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •