convert date function

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
halpavan2
Participant
Posts: 31
Joined: Fri Apr 18, 2008 5:44 am
Location: Hyderabad

convert date function

Post 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
pavan
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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.
pandeeswaran
halpavan2
Participant
Posts: 31
Joined: Fri Apr 18, 2008 5:44 am
Location: Hyderabad

Post 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.....
pavan
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Its clear that your input string doesn't match the format you specified .
Use single %m in the format .
pandeeswaran
premupdate
Participant
Posts: 47
Joined: Thu Oct 04, 2007 3:37 am
Location: chennai

Post by premupdate »

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

It might work..
Cheers,
prem
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
halpavan2
Participant
Posts: 31
Joined: Fri Apr 18, 2008 5:44 am
Location: Hyderabad

Post 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.
pavan
premupdate
Participant
Posts: 47
Joined: Thu Oct 04, 2007 3:37 am
Location: chennai

Post 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.
Cheers,
prem
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Thanks for your info..
pandeeswaran
Post Reply