date conversion

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
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

date conversion

Post by srimitta »

Hi Gurus,

I am trying to convert date format (yyyy-mm-dd TO dd/mm/yy). can i define the conversion in constraint or i have to write a routine, please help me with conversion procedure.

Thankyou
ms
nag0143
Premium Member
Premium Member
Posts: 159
Joined: Fri Nov 14, 2003 1:05 am

Post by nag0143 »

There are many ways to do this one way is to use

in derivation use

substr(input,9,2):/:substr(input,7,2):/:substr(input,1,2)


HTH
Nag
nag0143
Premium Member
Premium Member
Posts: 159
Joined: Fri Nov 14, 2003 1:05 am

Post by nag0143 »

nag0143 wrote:There are many ways to do this one way is to use

in derivation use

substr(input,9,2):/:substr(input,7,2):/:substr(input,1,2)


HTH
Nag
correction :)
substr(input,9,2):/:substr(input,7,2):/:substr(input,3,2)
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

I am trying to do conversion in transformation stage
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You need quotes:

link.column[9,2]:"/":link.column[7,2]:"/":link.column[3,2]
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, one position is off by one and you need quotes:

Code: Select all

substr(input,9,2):"/":substr(input,6,2):"/":substr(input,3,2) or
input[9,2]:"/":input[6,2]:"/":input[3,2]
:wink:

Only substring dates if you have complete confidence in their validity. You can also use Oconv and Iconv to convert between formats and validate the dates at the same time.

Code: Select all

Oconv(Iconv(YourField,"D-YMD[4,2,2]"),"D/DMY[2,2,2]")
If you want to add the status checking bits, do this in routine. Separate the two functions and use the Status function to check the success of the conversion. This is all in your online help, or many examples can be found here by searching.
-craig

"You can never have too many knives" -- Logan Nine Fingers
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

Hi,
i tried the below code in the constrain to change the date format
DSLink3.HIREDATE=Oconv(Iconv(DSLink3.HIREDATE,"D-YMD[4,2,2]"),"D/DMY[2,2,2]")

but i am getting the following error:
Attempting to Cleanup after ABORT raised in stage oraseqdate..Transformer_1
what exactly i have to use, constrain or routine to change Date format.
please explain me with the sample code.


Thanks
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

srimitta wrote:Hi,
i tried the below code in the constrain to change the date format
DSLink3.HIREDATE=Oconv(Iconv(DSLink3.HIREDATE,"D-YMD[4,2,2]"),"D/DMY[2,2,2]")
Just use:

Code: Select all

Oconv(Iconv(DSLink3.HIREDATE,"D-YMD[4,2,2]"),"D/DMY[2,2,2]")
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

Hi thanks for reply,
I tried your CODE but i am getting same error.
Input date formate is TIMESTAMP(1980-12-17 00:00:00) , I want to convert to 17/12/1980.
Thankyou
ms
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It helps when you let people know important things like that up front. :wink:

Try this:

Code: Select all

Oconv(Iconv(DSLink3.HIREDATE[1,10],"D-YMD[4,2,2]"),"D/DMY[2,2,2]")
-craig

"You can never have too many knives" -- Logan Nine Fingers
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

HI,
I am getting same error Attempting to Cleanup after ABORT raised in stage oraseqdate..Transformer_1
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

Hi,
My source is ODBC from oracle table with column name HIREDATE,format is Timestamp (1980-12-17 00:00:00). Here iam trying to convert date fromat to (17/12/1980), for this conversion i used CODE: Oconv(Iconv(DSLink3.HIREDATE[1,10],"D-YMD[4,2,2]"),"D/DMY[2,2,2]") In CONSTRAINT and in DERIVATION too, and populate flat table using SEQUENTIAL STAGE , But iam getting error: Attempting to Cleanup after ABORT raised in stage oraseqdate..Transformer_1 .
Please help me where to use this code (in derivation, constraint or routine)to get desired output format.
THANKYOU
MS
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

ODBC can automatically convert to internal date format, so that your transformations would not require the Iconv function.

To learn more about date conversions with Iconv and Oconv, go here.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply