SSIS convert to date issue

  • im developing an ssis package.

    while im in the sql server , there is a field that contains a text string , for example:

    December 13, 2008

    and so on...

    i want to convert it to 2008-12-13 00:00:00.000 or 2008-12-13 (its same for me)

    so, in the sql server i can do it with this statement:

    SELECT convert(datetime,myfiled, 107)

    FROM ....

    the question is , what is the equivalent statement to it within the SSIS 2008 ? (with derived column)

    thank you

  • avishain (1/21/2013)


    im developing an ssis package.

    while im in the sql server , there is a field that contains a text string , for example:

    December 13, 2008

    and so on...

    i want to convert it to 2008-12-13 00:00:00.000 or 2008-12-13 (its same for me)

    so, in the sql server i can do it with this statement:

    SELECT convert(datetime,myfiled, 107)

    FROM ....

    the question is , what is the equivalent statement to it within the SSIS 2008 ? (with derived column)

    Why not just do it in your source SQL as you described above? Or is the datasource not from SQL Server?

    If not, take a look at: http://toddmcdermid.blogspot.com/2008/11/converting-strings-to-dates-in-derived.html#!/2008/11/converting-strings-to-dates-in-derived.html

    HTH,

    Rob

  • the DS would be an XML file.... so i have to this within the ssis package 🙂

  • avishain (1/21/2013)


    im developing an ssis package.

    while im in the sql server , there is a field that contains a text string , for example:

    December 13, 2008

    and so on...

    i want to convert it to 2008-12-13 00:00:00.000 or 2008-12-13 (its same for me)

    so, in the sql server i can do it with this statement:

    SELECT convert(datetime,myfiled, 107)

    FROM ....

    the question is , what is the equivalent statement to it within the SSIS 2008 ? (with derived column)

    thank you

    Here is expression you needed

    (DT_STR,4,1252)YEAR((DT_DBDATE)"January 22, 2008") + "-" + (DT_STR,2,1252)MONTH((DT_DBDATE)"January 22, 2008") + "-" + (DT_STR,2,1252)DAY((DT_DBDATE)"January 22, 2008")

  • Here is expression you needed

    (DT_STR,4,1252)YEAR((DT_DBDATE)"January 22, 2008") + "-" + (DT_STR,2,1252)MONTH((DT_DBDATE)"January 22, 2008") + "-" + (DT_STR,2,1252)DAY((DT_DBDATE)"January 22, 2008")

  • type casting that column to dt_dbtimestamp should work

  • sqlbi.vvamsi (1/22/2013)


    type casting that column to dt_dbtimestamp should work

    Works like a charm 🙂

    thank you

Viewing 7 posts - 1 through 6 (of 6 total)

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