Problem with Date conversion

Database
Enthusiast

Problem with Date conversion

my source file is passing a date of "070206" yymmdd I need to convert the date to: "2007/02/06" can someone provide me the statement.

I have tried several methods, have not been successful...

3 REPLIES
Junior Contributor

Re: Problem with Date conversion

Hi Vince,

which methods? Why not succesfull?

Based on the CenturyBreak setting in dbscontrol you might have to add 20 to the string

select '070206' as d, '20' || d (date, format 'yyymmdd')

Or use ADD_MONTHS((d (date, format 'yymmdd')), 120)

Dieter

Enthusiast

Re: Problem with Date conversion

thank you Dieter, seems to have worked..  :) some times the answer is in front of your nose 

Enthusiast

Re: Problem with Date conversion

Another way:

SEL CAST(CAST(

ADD_MONTHS((CAST(CAST(070206 AS DATE FORMAT 'YYYY/MM/DD') AS CHAR(20))    ),1200) 

AS DATE FORMAT 'YYYY/MM/DD') AS CHAR(20))