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
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Date Conversion

Post by Hope »

I have to load Date(Flat file as source and datatype as Timestamp (23,3))
ModifiedDate = "04/02/2010 01:00:05 AM" in to
Target table (SQL table as) "2010-04-06 23:50:46.000"

Can anyone please help me with the conversion


Thanks
Hope
ETLJOB
Participant
Posts: 87
Joined: Thu May 01, 2008 1:15 pm
Location: INDIA

Post by ETLJOB »

If I understand correctly, your source date is "02/APR/2010" and the target date is "06/APR/2010". I don't think this is just a data type conversion. Do you have any specific logic that needs to be imposed in this conversion?
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Post by Hope »

Date formates are as below

Source Date =04/02/2010 01:00:05 AM and I have to do some conversion and Target Date should be 2010-04-02 01:00:05.000
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Split the date from the time, use the IConv/OConv functions to convert each component and then cat them back together. If you really need the milliseconds then just stick the ".000" on the end.

Both 'conversion' functions are well documented in the Help, give that a shot then let us know what you've tried and what issues (if any) you have with the approach.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Post by Hope »

I did split the date and timestamp and wrote a conversion for the date .

OConv(Iconv(DSLink4.ModifiedDate[1,10],"D/DMY[2,2,4]"),"D-Y-M-D")

The out put of this function is 15346.Its not giving me the target date as 2010-04-02 .
Is my logic right?Please correct me if I am wrong.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Pretty close. :wink:

The 'output' conversion mask is off and needs to be more like what you have on the input side:

Code: Select all

OConv(Iconv(DSLink4.ModifiedDate[1,10],"D/DMY[2,2,4]"),"D-YMD[4,2,2]")
Technically, the IConv mask can be simplified but that should work more better for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

OConv(Iconv(DSLink4.ModifiedDate[1,10],"D/DMY[2,2,4]"),"D-YMD[4,2,2]")
You are the creator of your destiny - Swami Vivekananda
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Post by Hope »

Thank you,

The logic works
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Shouldn't it have been "more betterer" Craig? Or the more informal "Mo' Bettah" that we use down South?

:-P
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:wink:
-craig

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