Page 1 of 1

Date Conversion

Posted: Wed Apr 07, 2010 1:50 am
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

Posted: Wed Apr 07, 2010 2:32 am
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?

Posted: Wed Apr 07, 2010 9:48 am
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

Posted: Wed Apr 07, 2010 10:59 am
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.

Posted: Wed Apr 07, 2010 11:06 am
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.

Posted: Wed Apr 07, 2010 11:14 am
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.

Posted: Wed Apr 07, 2010 11:15 am
by anbu

Code: Select all

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

Posted: Wed Apr 07, 2010 11:17 am
by Hope
Thank you,

The logic works

Posted: Thu Apr 08, 2010 8:33 am
by asorrell
Shouldn't it have been "more betterer" Craig? Or the more informal "Mo' Bettah" that we use down South?

:-P

Posted: Thu Apr 08, 2010 9:42 pm
by chulett
:wink: