Page 1 of 1

convert date function

Posted: Fri Nov 18, 2011 12:18 am
by halpavan2
Hello,

Can you please in coverting my date fuction.

My input is dataset --- transformer ---- DB2 stage.

Input is varchar field and output is date field

date coming from source is mm/dd/yyyy and i need to convert this to yyyy-mm-dd.

Ay help is much appreciated.

Thanks
Pavan

Posted: Fri Nov 18, 2011 12:31 am
by pandeesh
Hi, there are a lot of examples recently given for StringToDate conversion.
Please check those posts.
Still if you have any doubts, please let us know.

Posted: Fri Nov 18, 2011 12:38 am
by halpavan2
pandeesh wrote:Hi, there are a lot of examples recently given for StringToDate conversion.
Please check those posts.
Still if you have any doubts, please let us know.
Yeah.. i have see those posts..and applied the logic but still geeting the error

I haved the function like this StringToDate(Column name,"%mm/%dd/%yyyy")

here is the error

APT_CombinedOperatorController,2: Data string '2/28/2012' does not match format '%mm/%dd/%yyyy': the value for tag %mm has fewer characters than expected.

Please help me how to fix this.....

Posted: Fri Nov 18, 2011 12:44 am
by pandeesh
Its clear that your input string doesn't match the format you specified .
Use single %m in the format .

Posted: Fri Nov 18, 2011 12:55 am
by premupdate
Try StringToDate(Column name,"%(m,s)/%dd/%yyyy")

It might work..

Posted: Fri Nov 18, 2011 1:09 am
by pandeesh
premupdate wrote:Try StringToDate(Column name,"%(m,s)/%dd/%yyyy")

It might work..
I am curious what does that 's' in %(m,s) mean?
In his case, i believe the below will work:

Code: Select all

StringToDate(Column name,"%m/%dd/%yyyy")
(or)

Code: Select all

StringToDate(Column name,"%m/%d/%yyyy")
i think the second one has been tested by James recently.

Thanks

Posted: Fri Nov 18, 2011 2:09 am
by halpavan2
premupdate wrote:Try StringToDate(Column name,"%(m,s)/%dd/%yyyy")

It might work..
Hi,

I used this function StringToDate(Column name,"%(m,s)/%dd/%yyyy") and it worked for me....thanks for that..... i haved read what 's' specifies and it specify this option to allow leading spaces in date formats.

Thanks again.

Posted: Fri Nov 18, 2011 2:17 am
by premupdate
%(m,s)

indicates a numeric month of year field in which values can contain leading spaces or zeroes and be one or two characters wide.

Posted: Fri Nov 18, 2011 2:19 am
by pandeesh
Thanks for your info..