Modify Stage-Type conversion from string to date

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
bala_135
Premium Member
Premium Member
Posts: 156
Joined: Fri Oct 28, 2005 1:00 am
Location: Melbourne,Australia

Modify Stage-Type conversion from string to date

Post by bala_135 »

Hi,

I need to convert a input field which is string to date.Eg(1/12/2006).
I am using the function date_from_string(input column)..I am getting a fatal error.But when i use a proper date like 2006/12/01 the function is working fine.How to solve this problem.

Regards,
Bala.
bchau
Charter Member
Charter Member
Posts: 46
Joined: Tue Jan 18, 2005 7:39 am
Location: Japan
Contact:

Post by bchau »

Try date_from_string[%dd-%mm-%yyyy](input column)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The format string may need to be "%mm/%dd/%yyyy" (note the use of "/" as the separator character, to match the data) and it may be necessary to guarantee the leading zero on the month and day components.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bchau
Charter Member
Charter Member
Posts: 46
Joined: Tue Jan 18, 2005 7:39 am
Location: Japan
Contact:

Post by bchau »

oops my bad ray, i missed that. Thank you for the correction ;)
bala_135
Premium Member
Premium Member
Posts: 156
Joined: Fri Oct 28, 2005 1:00 am
Location: Melbourne,Australia

Post by bala_135 »

Hi Ray/bachu,

Thank you very much its working fine for the records which has got the exact format(%mm/%dd/%yyyy)but in my source i am having some records like 1/1/2006(month,date,year) here the month and date are not in the proper format so it issues a null in the target.

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

Post by ray.wurlod »

Read again "and it may be necessary to guarantee the leading zero on the month and day components". Use substring, concatenation and If constructs to get the format right.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply