Converting date formats

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Converting date formats

Post by vmcburney »

I have a date field coming in from DB2 in the format DD-MM-YYYY. I want to use it in a date function that needs it in the format YYYY-MM-DD. What's the easiest way to do the switch? Can do it in a modify stage or a transformer. Needs to handle one or two digit days and months.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Force the leading zeroes (Derivation) when extracting. Then you should be able to nest string_from_date in date_from_string in a Modify stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Guys,

Can't we break the input date DD-MM-YYYY into three subparts i.e DD,MM,YYYY and then combine them together in the required order YYYY-MM-DD?

Thanks,
Naveen
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Only if its data type is string. If its data type is date, you must first convert to string (string_from_date in Modify stage would do). Only string data types (including ustring) support substring operations.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Ray,

Thanks for the usefull information. Like always "Ray is the Best". :D

Thanks,
Naveen
Post Reply