Page 1 of 1

String to Date

Posted: Sun Jan 02, 2011 4:31 am
by eswar1
my source sequencial file has three attributes.
one dd-mm-yyyy format
two:mmddyyyy format
three: yyyy/dd/mm format
I wants convert string to date format the above all attributs.
How to validate and convert from string to date.
Pls help me.

Posted: Sun Jan 02, 2011 8:56 am
by chulett
:!: Split from this topic. When you have a problem or question, please start a new post rather than jumping on the end of someone else's conversation. That way we know what product and version you have and you have full control over the destiny of the post since you 'own' it. If you really feel that other post has value, add a link to it in yours much like I did above.

I've made assumptions about your environment (8.x,PX,UNIX), if any are incorrect please edit your post and change them appropriately. Thanks.

Posted: Sun Jan 02, 2011 9:00 am
by chulett
Now on to your question...

First tell us if you have these formats in different fields, meaning you know what format will be coming where, or if they are all mixed into a single source field. The former is pretty straight-forward while the latter will require you to identify the proper format to use in a series of if-then-else constructs... as one example of an approach.

Regardless, the solution is the same - the use of the StringToDate() function with a mask that matches the incoming date format so it knows how to convert it.