Convert String to Date

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
poorna_76
Charter Member
Charter Member
Posts: 190
Joined: Thu Jul 08, 2004 10:42 am

Convert String to Date

Post by poorna_76 »

Hi,

I am trying to insert date values into db2 table
which is defined as date(10).

I tried using both ODBC & DB2UDB stage.


When i use ODBC stage, iam getting the following error:

Illegal date/time value DATE1 = '01/01/2004'

When i use DB2UDB stage, iam getting the following error:

" Value treated as NULL
Attempt to convert String value "01/01/2004" to Date type unsuccessful "


I am using folowing code to convert into db2 format:

OCONV(ICONV(linkname.DATE1,"DMDY"),"D4/MDY[2,2,4]")

I tried inserting the Date value in all the possible DB2 formats,
by changing ICONV/OCONV formats,but no use.


Please help me out.
garthmac
Charter Member
Charter Member
Posts: 55
Joined: Tue Oct 21, 2003 9:17 am
Location: UK

Post by garthmac »

Hi,

You must output to the target database in DataStage internal format. For example, if your input date (Arg1) is in the format YYYYMMDD, then use the following in a routine:

Ans = Iconv(Arg1, "D-YMD[4,2,2]")
vinnz
Participant
Posts: 92
Joined: Tue Feb 17, 2004 9:23 pm

Re: Convert String to Date

Post by vinnz »

I am using folowing code to convert into db2 format:

OCONV(ICONV(linkname.DATE1,"DMDY"),"D4/MDY[2,2,4]")

I tried inserting the Date value in all the possible DB2 formats,
by changing ICONV/OCONV formats,but no use.
You could use the transform DateGenericToODBC to convert your date into an ODBC format or maybe use something similar to to this

Code: Select all

OCONV(ICONV(linkname.DATE1,"DMDY"),"D-YMD[4,2,2]") 
Post Reply