Converting field length to 8 by padding with a 0 on left.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Deana Rivas
    New Member
    • Sep 2010
    • 2

    Converting field length to 8 by padding with a 0 on left.

    I have a field that has some 7 length data. All incoming data for this field will now be 8 characters, however I would like to convert the existing 7 character data to 8 by left padding with a 0. What is the easiest way to do this?

    Thank You!
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Use CAST() to convert any numeric data into string. Add 8 zeroes in the left of your data. Retrieve 8-digit from the right using RIGHT() function.

    Happy Coding!!!

    ~~ CK

    Comment

    • Deana Rivas
      New Member
      • Sep 2010
      • 2

      #3
      Thank You.

      If the field that i am wanting to update {date_of_call} is already in a string format, how would i write this?

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4

        Add 8 zeroes in the left of your data. Retrieve 8-digit from the right using RIGHT() function.
        Happy Coding!!!

        ~~ CK

        Comment

        Working...