Data conversion

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
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Data conversion

Post by ntr »

Hi,

I am havin a date column of varchar .
I want to change to Date format.
my data : 3/21/2011
0001-02-02.

how can i change to date format .
Can any one have any idea?.

Thanjs & Regards
kogads
Premium Member
Premium Member
Posts: 74
Joined: Fri Jun 05, 2009 5:36 pm

Post by kogads »

Can you please give your i/p and o/p formats..The question is not clear
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There is no "output format" here if the target is a date. So the question remains, are those two examples of what can come in as your date string?

3/21/2011
0001-02-02

So, both m/d/y & y-m-d formats in the same field? If not then please explain what you will be getting with additional examples, please.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi ,

These are coming on the same column.
As 2 records.
so i want to load it into the oracle database.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You're going to need some If..Then..Else logic to differentiate the formats, and apply the appropriate conversion in each case.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi,
Can you give an example i am new to datastage
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Are those the only two formats or have you seen others in that field?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi Craig,

I think in future 10/21/2011

will also come
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

10/10/2011

In this case which is date and which is month?

Handling date column is always tricky and source should say how it is!!

DS User
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The If..Then..Else construct determines which of the two formats is used in the current row. It is sufficient to test the first four characters being numeric (which indicates YYYY-MM-DD format in your case).

Code: Select all

If Num(InLink.TheString[1,4]) Then StringToDate(InLink.TheString,"%yyyy-%mm-%dd") Else StringToDate(InLink.TheString,"%m/%d/%yyyy")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi,
I.e mm/dd/yyyy format
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No, date format, for example 000001101101001000101010100010110101
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi to all,
Please give solution for this.Still i am not able to get the solution.

Thanks
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Solution has been very clearly given above. What part of it do you have a question about?
Choose a job you love, and you will never have to work a day in your life. - Confucius
Post Reply