2
SELECT to_char(START_D,???)

The issue I have above is that I can't seem to find the right parameter for the above to work. The date is numeric e.g 1102. I want to turn this into a character.

Actually even better is to turn the numeric field to 11/02, which is Day/Month. The reason why I want to turn it into character is that it outputs without the zeros in front. e.g 712 instead of 0712.

Thanks in advance!

0

2 Answers 2

2

Try this:

to_char(START_D, '0000')
1
  • Thanks it turned it into character with the zeros in front. Any ideas how to get the '/' in there? e.g. 11/02 from 1102.
    – Lorbat
    Commented Dec 15, 2011 at 11:09
1

As I understand it, Netezza uses a variant of PostgreSQL. If so, try:

to_char(START_D,'DD/MM')

to turn a date into a day/month string.

To turn a 4-digit integer into a slash-separated string, try:

substring(to_char(START_D,'9999'),2,2)||'/'||substring(to_char(START_D,'9999'),4,2)

Replace the '9999' with '0000' if you want 3-digit integers to be 0-padded.

3
  • Problem is: START_D is an int, not a date Commented Dec 15, 2011 at 11:12
  • @DanielHilgarth - see amended answer.
    – user359040
    Commented Dec 15, 2011 at 11:20
  • Fantastic! Thats what I need. I changed the '9999' to '0000' to give the zero in front.
    – Lorbat
    Commented Dec 15, 2011 at 11:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.