convert 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
tanaya.deshpande@tieto.co
Participant
Posts: 94
Joined: Sun Jul 18, 2010 11:35 pm

convert string to date

Post by tanaya.deshpande@tieto.co »

I want to convert a date like 22Feb11 which is varchar in source to date datatype in format YYYYMMDD ..I know I must use stringtodate ...

but what formating i shud use?? I have used

StringToDate(DSLink100.PalanedDeliveryDate,"%yyyy-%mm-%dd")

but its not working..
GJ_Stage
Participant
Posts: 131
Joined: Mon Oct 27, 2008 6:59 am

Post by GJ_Stage »

Try this :

StringToDate(DSLink100.PalanedDeliveryDate,'%yyyy-%mm-%dd')

Please provide what is error message are you getting?
iHijazi
Participant
Posts: 45
Joined: Sun Oct 24, 2010 12:05 am

Post by iHijazi »

I don't really think that "22Feb11" is understood by DS compiler.

StringToDate is NOT magic function, it coverts datatype and help you a bit with your format if it's related to some kind of standard, data standard format I mean.

So what to do? Reformat the string 22Feb11 to something more understandable to a compiler first, then use that function.
Not only thoughts, but a little bit of experience.
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Try in this manner.

StringToDate(DSLink100.PalanedDeliveryDate,"%dd%mmm%2000yy")
Cheers
Ravi K
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, the 'mask' you use in StringToDate() must match the incoming string's format. And that will get you a Date which has no external format. If you really need something in an external format like YYYYMMDD you'll need to also use DateToString() afterwards, again with the appropriate mask.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply