How to convert 20070625 to Date Format(mm/dd/yyyy) in PX

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
Shadab_Farooque
Participant
Posts: 21
Joined: Tue Apr 24, 2007 12:39 am

How to convert 20070625 to Date Format(mm/dd/yyyy) in PX

Post by Shadab_Farooque »

I am having source data format as yyyymmdd which is of integer type(Eg:20070728).I have to convert it in to Date format and load in Oracle table.The column is "date" type in Oracle.

This is a Parallel Job.

Please advise
Shadab Farooque
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

You can try stringtodate() in transformer stage or date_from_string() in the modify stage.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
thebird
Participant
Posts: 254
Joined: Thu Jan 06, 2005 12:11 am
Location: India
Contact:

Re: How to convert 20070625 to Date Format(mm/dd/yyyy) in PX

Post by thebird »

Shadab_Farooque wrote:I am having source data format as yyyymmdd which is of integer type(Eg:20070728).I have to convert it in to Date format and load in Oracle table.The column is "date" type in Oracle.
Date datatype in Oracle is "TimeStamp" for DataStage.So you would have to convert your input interger value into a TimeStamp.

You can use the substring funtion - and then convert the formatted into a Timestamp using the StringToTimestamp function after appending a time component (say 00:00:00) to your date.

Aneesh
------------------
Aneesh
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Read the integer as character by specifying TO_CHAR() in the sql select and then in the transformer provide the following

Code: Select all

StringToDate(in.Date, "%yyyy%mm%dd")
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Shadab_Farooque
Participant
Posts: 21
Joined: Tue Apr 24, 2007 12:39 am

Post by Shadab_Farooque »

I got the solution so I am marking this as resolved.

Thanks everyone for their suggestions.

I used the following in the transformer to convert date(20070718) to date type 07/18/2007.

StringToDate(DSLink3.Field005[5,2]:'/':DSLink3.Field005[7,2]:'/':DSLink3.Field005[1,4],"%mm/%dd/%yyyy").

Thanks
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

I guess you forgot to mark the post as mentioned. :wink:
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Shadab_Farooque
Participant
Posts: 21
Joined: Tue Apr 24, 2007 12:39 am

Post by Shadab_Farooque »

kumar_s wrote:I guess you forgot to mark the post as mentioned. :wink: ...
Thanks for the info.. Marking it as resolved
Shadab Farooque
Post Reply