convert char 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

Post Reply
deva
Participant
Posts: 104
Joined: Fri Dec 29, 2006 1:54 pm

convert char to date

Post by deva »

Hi
In Source I have two columns one is eff_month, eff_year. those data type is char.
I want to load in target as due_date (data type date) as month/year.

I am doing concadination using to_date. in oracle it is working but in data stage I am getting error.

Can any one help me how to do this rek.

Thanks in Advance
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Re: convert char to date

Post by sud »

Hi, in datastage you have to have year, month and date all three in a date. The error must be because of that.
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Please post what you tried in DataStage. You can concatenate the columns and then use the StringToDate() function.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You posted this in the PX forum, but marked it as a Server job ... which is it?
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

ArndW,

He don't have the day from the source. He just has month and year. Then how can he concatenate and use StringToDate() function without a day?
Thanks and Regards!!
dspxlearn
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

StringToDate(InLink.Eff_Year : "-" : InLink.Eff_Month : "-01")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Ray,

So, below code along with the date format masking, we will be getting all '01' for days right?

Code: Select all

StringToDate(InLink.Eff_Year : "-" : InLink.Eff_Month : "-01") 
How about the below code.I guess we will be getting only the month/year.

Code: Select all

MonthFromDate(StringToDate(InLink.Eff_Year : "-" : InLink.Eff_Month : "-01","%yyyy-%mm-%dd")) : '/' :YearFromDate(StringToDate(InLink.Eff_Year : "-" : InLink.Eff_Month : "-01","%yyyy-%mm-%dd")) 
Ofcourse, if the target is a text file and not the database.
Thanks and Regards!!
dspxlearn
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

dspxlearn wrote:Ray,

So, below code along with the date format masking, we will be getting all '01' for days right?

Code: Select all

StringToDate(InLink.Eff_Year : "-" : InLink.Eff_Month : "-01") 
How about the below code.I guess we will be getting only the month/year.

Code: Select all

MonthFromDate(StringToDate(InLink.Eff_Year : "-" : InLink.Eff_Month : "-01","%yyyy-%mm-%dd")) : '/' :YearFromDate(StringToDate(InLink.Eff_Year : "-" : InLink.Eff_Month : "-01","%yyyy-%mm-%dd")) 
Ofcourse, if the target is a text file and not the database.
Very funny :lol: :lol: :lol:

InLink.Eff_Year and InLink.Eff_Month already has year and month. So if he just needs a string with year/moth, he can directly concatenate them.
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Sud,

Original poster wanted his target datatype to be of Date datatype. And i guess, we cannot load a value of 'date' datatype without a day in it. :lol:
Thanks and Regards!!
dspxlearn
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Re: convert char to date

Post by paddu »

deva wrote:Hi
In Source I have two columns one is eff_month, eff_year. those data type is char.
I want to load in target as due_date (data type date) as month/year.

I am doing concadination using to_date. in oracle it is working but in data stage I am getting error.

Can any one help me how to do this rek.

Thanks in Advance
why same post at two different locations :roll:

viewtopic.php?t=116304
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Re: convert char to date

Post by sud »

paddu wrote: why same post at two different locations :roll:

viewtopic.php?t=116304
Sadly, some people REALLY take this site for granted. :evil: :evil:
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
Post Reply