locked
Error while converting Oracle Timestamp to Sql Server Timestamp (datetime) - "Invalid date Format" RRS feed

  • Question

  • I am populating oracle source in Sql Server Destination. after few rows it fails it displays this error:

    [OLE DB Destination [16]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available.  Source: "Microsoft OLE DB Provider for SQL Server"  Hresult: 0x80004005  Description:
     "Invalid date format".

     

    I used this script component using the following code in between the adapters, However after 9,500 rows it failed again giving the same above error:

     

     

    To convert Oracle timestamp to Sql Server timestamp

    If Row.CALCULATEDETADATECUST_IsNull = False Then

    If IsDate(DateSerial(Row.CALCULATEDETADATECUST.Year, Row.CALCULATEDETADATECUST.Month, Row.CALCULATEDETADATECUST.Day)) Then

    dt = Row.CALCULATEDETADATECUST

    Row.CALCULATEDETADATECUSTD = dt

    End If

    End If

     

    I don't know if my code is right . Please inform, how i can achieve this.

    Tuesday, June 19, 2007 5:03 AM

Answers

  •  

    I've put up an article for this on my blog.

     

     

    Cast this Oracle timestamp Column REQUESTED_ETA_DATE_CUST as below:

    Decode(trunc((Extract(YEAR from REQUESTED_ETA_DATE_CUST))/1753), 0,'01/01/1753 12:00:00 AM', TO_CHAR(REQUESTED_ETA_DATE_CUST, 'MM/DD/YYYY hh:mmTongue Tieds AM')) as REQUESTED_ETA_DATE_CUST

     

    Or 

     

     Go for  filtering valid ranges using SSIS transform  after casting into a accepted datetime format.

     

     

     

    Wednesday, July 25, 2007 7:35 AM

All replies

  • What is the value of the offending row? Redirect the error rows from the SQL dest and see what the offending value is.

    The fact that it gets through 9500 rows and then dies means your logic is right but there is a dodgy row.
    Tuesday, June 19, 2007 8:05 AM
  • Thanks for your support, Crispin,

      I redirected the output at destination (Fail Point) as you said and can see that some columns are displaying the Errors  instead of the actual data that  gives the clue about which is invalid)

     

    Column 5

    Error: Year, Month and day parameters describe an unrepresnatable date and time...

     

    I doubt that the DateSerial function in the script component is unable to extract some formats..

     

    So,

    1) Does anybody know which representations and range of Oracle (timestamp) is not allowed in Sql Server (Datetime)
       2) Do we have a stable code that can perform  Oracle timestamp to Sql Server conversion here

     

     

    Thanks

    Subhash Subramanyam

     

    Wednesday, June 20, 2007 5:46 AM
  • Hi Experts in SSIS forum,

      Thanks to LoRez who has raised this question this month again.. I am still  having the same problem in SSIS.  I have an Oracle timestamp Source Columns that should be populated into Sql Server Datetime columns. Though I am aware of the ranges valid for both the cases, I was unable to frame it properly. . The expression (This only checks the Date Part , I wanted code that converts the time part of the Oracle timestamp into Sql Server Datetime) I have used to convert this is:

     

    (!ISNULL(REQUESTED_ETA_DATE_CUST) && DATEPART("yyyy",REQUESTED_ETA_DATE_CUST) > 1752 && DATEPART("yyyy",REQUESTED_ETA_DATE_CUST) < 9999) ? REQUESTED_ETA_DATE_CUST : NULL(DT_DBTIMESTAMP)

     

    Though the expression syntax is valid, it still gives error when I run the dataflow. The error is:

    [Derived Column [136]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "component "Derived Column" (136)" failed because error code 0xC0049067 occurred, and the error row disposition on "input column "REQUESTED_ETA_DATE_CUST" (372)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.

     

     

    Though http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/7121008802  helps to create a trigger, but not the way we can achieve using SSIS.

     

     

    Greatly Appreciate if anybody can pointer or paste the Expression or  .NET  code that can convert Oracle timestamp into Sql Server Datetime without issues

     

    Thanks

    Subhash Subramanyam

     

     

    Thursday, July 19, 2007 10:30 AM
  • Dear Umachandar, Thanks for briefing up the approach.
    I'd appreciate if you go one step ahead to help my case work.Oracle Timestamp in my case is of the format 'MM/DD/YYYY hh:mm:ss.nnn'  and I do not have any control over oracle source. Somehow I must be able to use this to populate the Sql Server datetime.  We know that the year should be grater that 1752  which we can validate using above expression. But Validating TimePart seems to be difficult. I tried casting to string, but due to omission of leading zeros makes it difficult to substring that. So do you have a solution for this?
     

    Umachandar's Reply

    Oracle timestamp range subsumes that of SQL Server's datetime range. So you will not have any issues as long as you use the ISO 8601 format to specify the values (YYYY-MM-DDT hh:mm:ss.nnn). This will ensure that the value will be stored correctly irrespective of collation settings on either servers or Oracle session setttings. You can use timestamp with appropriate precision on Oracle side (timestamp(3) is closest) to match SQL Server datetime.
     
    Migrating values from Oracle to SQL Server is a different ballgame. You will lose precision, values etc. Oracle has more richer support and wider ranges & ANSI SQL implementation.

     

    Thanks
    Subhash Subramanyam
    Friday, July 20, 2007 3:03 PM
  •  

    I've put up an article for this on my blog.

     

     

    Cast this Oracle timestamp Column REQUESTED_ETA_DATE_CUST as below:

    Decode(trunc((Extract(YEAR from REQUESTED_ETA_DATE_CUST))/1753), 0,'01/01/1753 12:00:00 AM', TO_CHAR(REQUESTED_ETA_DATE_CUST, 'MM/DD/YYYY hh:mmTongue Tieds AM')) as REQUESTED_ETA_DATE_CUST

     

    Or 

     

     Go for  filtering valid ranges using SSIS transform  after casting into a accepted datetime format.

     

     

     

    Wednesday, July 25, 2007 7:35 AM