Date conversion again...

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Anand K
Participant
Posts: 17
Joined: Thu Nov 20, 2003 7:19 am

Date conversion again...

Post by Anand K »

Hi All

I have a date coming in from a sequential file as "20031010" (YYYYMMDD) which I need to convert into 2003/10/10 (YYYY/MM/DD) and store in a Oracle table

Please help me how to get this.


Thnx in advance

Anand K
essaion
Participant
Posts: 18
Joined: Tue Nov 04, 2003 8:55 am
Contact:

Post by essaion »

Please make a search before posting an issue that can easily be found within this forum : in the upper navigation frame, click "search", the fill the "search for" field with your keywords (could be "date conversion", for an example), make sure the radio button "match all keywords" is ticked, then run the search.

"Help yourself so God can help you"...

Tip : you can also look at the designer help or the documentation provided together with datastage...
Aurelien
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Date conversion again...

Post by chulett »

Anand K wrote:I have a date coming in from a sequential file as "20031010" (YYYYMMDD) which I need to convert into 2003/10/10 (YYYY/MM/DD) and store in a Oracle table
First off, welcome to the Forums!

As you've guessed, this issue has been covered before and lots of information can be found by searching. Looking for "iconv", "oconv" and "status" will net you what you need to do the job right. Your other option would be to substring it apart and paste it back together again the way you want it, but then you'd never know if it's good or not until Oracle spits it back at you. :(

If you are using the OCI stage for your Oracle work, you typically want to get it into YYYY-MM-DD format. Depends on the data type you choose, I generally stick with Timestamp and make sure there is a time portion, even if it is all zeroes. If you haven't already, read the .pdf docs for the OCI plugin, it will explain how it works and what it is expecting.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Re: Date conversion again...

Post by Teej »

Actually, if the Oracle output is a Varchar, a string chopping routine can be used.

You know blah[1,4] : "/" : blah[5,2] : "/" : blah[7,2]

-T.J.
Developer of DataStage Parallel Engine (Orchestrate).
auvray.muriel
Participant
Posts: 43
Joined: Wed Feb 19, 2003 7:17 am
Location: France - Paris
Contact:

Post by auvray.muriel »

hello,

you can use the routine "DateTimeStamptoOraOCI" which is in the following tree structure:
Routines/sdk/Date

Code: Select all

RoutineName = 'DateTimeStamptoOraOCI'

    If Arg1 Then
   	Ans = Arg1[1,4]:"/":Arg1[5,2]:"/":Arg1[7,2]:" 00:00:00"
    End Else
   	Ans = Arg1
    End

Bye :wink:

Muriel
Post Reply