File input "1-Apr-97" how to convert in 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
Mhasan
Participant
Posts: 38
Joined: Wed Apr 19, 2006 10:03 pm
Location: Bangalore

File input "1-Apr-97" how to convert in date

Post by Mhasan »

Iam readign CSV file using squential stage , input data from that it coming like 1-Apr-95 , 1-sep-00 how to Load that into Oracle DB
I have tried stringtodate(input,"%dd-%mmm-%yy") But it is working only for data like
27-sep-95 not for 1-Apr-07 , how to overcome this Issue.

Thanks
Hasan
Thanks
M A hasan
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

Try If Len(input) = 8 then stringtodate("0" : input,"%dd-%mmm-%yy") Else stringtodate(input,"%dd-%mmm-%yy").
What it does is check if the length of the string is 8 i.e "1-Apr-07" then it will append the input with a leading zero and then convert it to date.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

And add 2 more ELSE clauses for double-digit days then you are ready.
Post Reply