Netezza SQL issue - month issue

How do you retrieve only a month from a date in netezza SQL?

The date shows as 05DEC2010 .

I tried to extract ( MONTH FROM CONTACT_DATE)although it does not work. Any ideas? I don't want to just extract

+3
source share
4 answers

It would seem that your contact_date field is not a date field. You should probably use:

extract(month from (contact_date::date))
+5
source

Made the answer above.

SELECT EXTRACT(MONTH FROM ('17NOV2011' :: DATE)) AS MONTH_NUMBER
+1
source

If the date does not work, you can control it with to_date

select extract(MONTH FROM to_date('05DEC2010','DDMonYYYY'))

Also works

select date_part('Month',to_date('05DEC2010','DDMonYYYY'))

Also works

select to_char(to_date('05DEC2010','DDMonYYYY'),'MM')
+1
source

You can use it select month('05DEC2010')as an easier and more efficient way!

0
source

Source: https://habr.com/ru/post/1781457/


All Articles