Page 1 of 1
convert string to date
Posted: Tue Mar 22, 2011 1:58 am
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..
Posted: Tue Mar 22, 2011 2:28 am
by GJ_Stage
Try this :
StringToDate(DSLink100.PalanedDeliveryDate,'%yyyy-%mm-%dd')
Please provide what is error message are you getting?
Posted: Tue Mar 22, 2011 2:52 am
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.
Posted: Tue Mar 22, 2011 3:03 am
by Ravi.K
Try in this manner.
StringToDate(DSLink100.PalanedDeliveryDate,"%dd%mmm%2000yy")
Posted: Tue Mar 22, 2011 7:04 am
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.