Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2001
    Chicago, IL

    Question Unanswered: Losing leading zeros when casting numeric

    I am casting a date to character in order to substring some of the components (mm, dd, etc). How do I NOT lose the leading zeros when it casts to character? I've had to put in case statements to substring correctly depending on what the date is (if it's less than 10, it drops that leading 0 and becomes 30703 instead of 030703). Is there anything I can do other than using the case statements to get around this issue? I have the same problem with times.

    Thanks for any help.

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 5
    Instead of casting it, try running it through the CHAR function. The manual states that the resulting string is always 10 characters long. The same technique will work for time values as well.


Posting Permissions

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