Need to load date from datepart from a table to a file

  • I have a table with datetime column something like this : 08-09-2016 00:00:00

    I would like to get only 08-09-2016 from this column while loading to a text file.

    I used derived column with expression something like this : (DT_DBDATE)[Date]

    This is still not working. Need help

    Thanks.

  • The CONVERT function supports the format you want to use. Just apply it to a column instead.

    SELECT CONVERT(Varchar(10), GETDATE(), 110);

  • Ed Wagner (8/10/2016)


    The CONVERT function supports the format you want to use. Just apply it to a column instead.

    SELECT CONVERT(Varchar(10), GETDATE(), 110);

    Do T-SQL functions actually work inn SSIS, Ed? I thought you had to use "DTS" functions only unless it was in a T-SQL script task or stored procedure.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I tried the same...but no use. it still appends 0's for hh:mm:ss. 2016-07-18 00:00:00

    I don't need 0's appended at last.

  • Jeff Moden (8/10/2016)


    Ed Wagner (8/10/2016)


    The CONVERT function supports the format you want to use. Just apply it to a column instead.

    SELECT CONVERT(Varchar(10), GETDATE(), 110);

    Do T-SQL functions actually work inn SSIS, Ed? I thought you had to use "DTS" functions only unless it was in a T-SQL script task or stored procedure.

    Doh! I guess I wasn't caffeinated enough yet. Thanks.

    Komal, skip my post. Sorry about that.

  • To get a specific format from a date into a file, you need to convert it to string.

    It's certainly easier to format with a SQL query than with SSIS. If you don't want to use a query as a source in your SSIS package, create a view from the table which returns all the desired formats and use that as a source. Remember to keep your columns as strings, as that the only way to ensure the desired format.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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