Lorbat
Lorbat

Reputation: 385

Netezza SQL - give a parameter

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!

Upvotes: 2

Views: 1661

Answers (2)

user359040
user359040

Reputation:

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.

Upvotes: 1

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174279

Try this:

to_char(START_D, '0000')

Upvotes: 2

Related Questions