Converting 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

allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

kbsuryadev wrote:sorry i forgot these % in the code

try this in the derivation

StringToDate(input,"%mm/%dd/%yyyy")

and do the same in the output as i mentioned in the other reply
i tried but same error..
kbsuryadev
Premium Member
Premium Member
Posts: 46
Joined: Wed Jun 06, 2007 10:32 am

Post by kbsuryadev »

what is your input ? database/file

what is the datatype.?

i just tested a job it works fine
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Change

StringToDate(input,"%mm/%dd/%yyyy")

to this

StringToDate(input,"%mm\%dd\%yyyy")
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

kbsuryadev wrote:what is your input ? database/file

what is the datatype.?

i just tested a job it works fine
its a file ..

actually iam doing column import of data coming from flat file...

Next in transformer iam trying to convert to specific date format...

is any thing i should do in column import stage for that column...
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Please do what I suggested and it will work.
kbsuryadev
Premium Member
Premium Member
Posts: 46
Joined: Wed Jun 06, 2007 10:32 am

Post by kbsuryadev »

I just did a test it works fine

i used this data

input- 03/13/2010 .. output comes as 2010/03/13
use input datatype as (varchar) -10

in the transformer use this code

StringToDate(DSLink3.DATE,"%mm/%dd/%yyyy")

Output datatype ( DATE)

go to columns tab (output stage) and edit column meta data properties window

and under parallel properties

chose format string=%yyyy/%mm/%dd
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Yes -that will work also. There are many ways to work this issue.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Try to capture all the distinct values from the source by using a Remove Duplicates stage and try scanning them through to see if there are any data quality issues. We had a similar issue where business users started manually entering dates into the field and used their own formats such as 2010/03/13 (notice the slashes) or interchanged month and date positions within the date. The issue definitely looks like a data quality issue at source.
Kris

Where's the "Any" key?-Homer Simpson
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

kbsuryadev wrote:I just did a test it works fine

i used this data

input- 03/13/2010 .. output comes as 2010/03/13
use input datatype as (varchar) -10

in the transformer use this code

StringToDate(DSLink3.DATE,"%mm/%dd/%yyyy")

Output datatype ( DATE)

go to columns tab (output stage) and edit column meta data properties window

and under parallel properties

chose format string=%yyyy/%mm/%dd

It worked

Thanks for all suggestions...

Iam marking this thread resolved...
Post Reply