tags:

views:

2258

answers:

4

We have a Netezza table that contains dates stored in a numeric YYYYMMDD format (eg 20090731).

What is the best Netezza syntax to use to convert this into date format?

eg

SELECT somefunction(20090731) as NZDATE

?

A: 

aah - my efforts were thwarted originally due to invalid dates. The below DOES work as long as you wrap it in a case when statement to catch the bad ones!

select  to_date(substring(20090731 from 1 for 8),'YYYYMMDD') as NZDATE

(obviously the 20090731 should be replaced with the name of the numeric variable..)

Bazil
A: 

very nice .. its working for me .. Thanks, Arun M

Arun
A: 

Hi,

This is new syntax for SUBSTRING function. working well. Thanks a lot. I'm expecting more related syntax of Netezza .

Thanks, Sudhagar V

A: 

Hi,

U can use this one as a best one.

SELECT TO_DATE('20090731','YYYYMMDD') as NZDATE

Thanks, Sudhagar.