SSIS Data conversion

  • Need to convert databasetimestamp to Numeric(8,0) and Numeric(6,0)

    SQL Server Conversions :

    select convert(Numeric(8,0) ,(CONVERT(VARCHAR,GETDATE(),112))) - 20120410 (yyyymmdd)

    select convert(Numeric(6,0) ,(CONVERT(VARCHAR(6),GETDATE(),112))) - 201204 (yyyymm)

    How to achieve this in SSIS

    Can anybody advise?

  • I would still do this in TSQL. It's much easier there, as there are no easy date formatting functions in the SSIS expression language.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen,

    I managed to write an SSIS expression for this

    Derived column 1 - Convert dbtimestamp to DT_WSTR (Add new column)

    Derived column 2 - Expression (DT_STR, 4, 1252)DATEPART("yyyy", GETDATE()) +

    RIGHT("0" + (DT_STR, 2, 1252)DATEPART("mm", GETDATE()), 2) +

    RIGHT("0" + (DT_STR, 2, 1252)DATEPART("dd", GETDATE()), 2 (Replace Derived column1)

    Dataconversion - Convert Unicode string to DT_NUMERIC(8,0)

    Thanks...

  • Like I said, much easier in TSQL 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply