0

Trying to add a zero before the value if it's less than 10

eg:2001-5-9 as 2001-05-09

1 Answer 1

1

Look into to_char() for date formatting:

http://www.postgresql.org/docs/current/static/functions-formatting.html

select to_char(foo, 'YYYY-MM-DD')

If it's not a date already, cast it accordingly

select to_char(foo::date, 'YYYY-MM-DD')
Sign up to request clarification or add additional context in comments.

3 Comments

Actually its not for date field..Its integer field
i dont want to have case statements..anything simple way to append?
@user3007361 It cannot be an integer field. (it could be the concatenation of the string representations of three integer fields) please reformulate your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.