Integer to Date 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
senthilmp
Participant
Posts: 85
Joined: Mon Sep 22, 2008 6:11 am

Integer to Date conversion

Post by senthilmp »

Hi,

My source is having one of the 'Date Field' as an integer type , and i want this to be converted as Date type in the target.

eg: the source contains

20080325 i want this to be stored as date format in the target, can any one help out in this?

Regards,
Senthil MP
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can work with it as a string input. What have you attempted so far?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Server job as marked or Parallel job per the forum you posted in?
-craig

"You can never have too many knives" -- Logan Nine Fingers
srinivas.g
Participant
Posts: 251
Joined: Mon Jun 09, 2008 5:52 am

Post by srinivas.g »

througth iconv oconv function

oconv(iconv(columnname),D-DMY),D-DMY[2,2,4])
Srinu Gadipudi
senthilmp
Participant
Posts: 85
Joined: Mon Sep 22, 2008 6:11 am

Post by senthilmp »

Hi, now its converting but still while inserting into the target table am getting the following error

"Attempt to convert String value "15-08-2005" to Date type unsuccessful"

I tried with both DATA and TIMESTAMP in target but i got this error
srinivas.g
Participant
Posts: 251
Joined: Mon Jun 09, 2008 5:52 am

Post by srinivas.g »

try this one
OCONV(ICONV(columnname,'D-MDY[2,2,4]'), 'D-YMD[4, 2, 2]')

datatype is timestamp
Srinu Gadipudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

OK, Server job it seems. Rather than attack this piecemeal, how about details like target database & stage you are using? Custom or generated SQL? All affect the answer.
-craig

"You can never have too many knives" -- Logan Nine Fingers
senthilmp
Participant
Posts: 85
Joined: Mon Sep 22, 2008 6:11 am

Post by senthilmp »

Hi all,

thanks for the response, i got it by searching DSXchange further,

the solution is have to use only ICONV and not the combination of OCONV & ICONV.

Gr8 Forum
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... DB2? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
senthilmp
Participant
Posts: 85
Joined: Mon Sep 22, 2008 6:11 am

Post by senthilmp »

No its Oracle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In that case, using IConv only doesn't make much sense, but I'll take your word for it that it is actually working for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply