converting string to date for DB2

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
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

converting string to date for DB2

Post by major »

Hi all,

I am loading a seq file to a DB2 db.
I have a date field column in the table
when i try to load the value in this column "cannot able to convert sting to date" warning is coming.

I have been using the below function but of no use

OConv(IConv(FM_FLEETS_HASH_FILE.START_DT,"D"),"D-YMD[4,2,2]")

Please help me in this regard.

Thanks,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't work with DB2 but from the forums here I think the DB2 stage wants dates in internal format, so you might try just the IConv part.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The error arises from the Iconv() function. Whatever the format of your date is, it is not understood by "D" as a conversion, which expects the date format of your locale (had you provided your location I could probably be more specific about that). Try

Code: Select all

Iconv(FM_FLEETS_HASH_FILE.START_DT,"DYMD")
if your date is in year - month - day order.

I agree with Craig that you probably don't need the Oconv() function when sending dates to DB2.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

Post by major »

Thanks Ray,

I converted the input date to YEAR-MONTH-DAY format and applied the
ICONV(date,'DYMD') and its working fine.

Thanks all,
Post Reply