Import String Date in Derived column

前端 未结 1 718
[愿得一人]
[愿得一人] 2020-12-04 03:00

I have a string date being read in from a file in the following format and is giving me cast error.

Oct 25 2011 10:18:10:756PM

I am using D

相关标签:
1条回答
  • 2020-12-04 03:33

    Detailed answer but I beg to differ as to whether "SSIS cannot recognize the date format provided in the question."

    Perhaps if it was restated as "SSIS cannot recognize the supplied date format without help." The root issue in this case, is that by default the date and number parsing routines are locale aware. In general, this a good thing, except when it's not. I first stumbled over this when I was dealing with dates in a format of ccyymmdd coming off a mainframe. As others indicated, it'll parse in tsql, why not SSIS? There are plenty of articles out there advocating slicing and dicing the string data to make it into a valid datetime but why go through all that hassle?

    Given this as sample input data (tab delimited).

    LongDateDesiresFastParse    Gibberish
    Oct 25 2011 10:18:10:756PM  Hello world
    Oct 24 2010 10:18:10:756PM  Hello 2010 world
    Oct 23 2009 10:18:10:756PM  Hello 2009 world
    Oct 22 2008 10:18:10:756PM  Hello 2008 world
    

    And a package that looks like this,

    Control flow

    By changing one setting on the Flat File Source, I can make the package fail or not.

    Generic data flow

    Right click on the Flat File Source and select "Show Advanced Editor." On the "Input and Output Properties" tab, expand the Output Columns and find the column containing the date. Change the FastParse setting from False to True.

    Setting fast parse in a flat file source

    When I ran it, the package originally failed as it was losing precision storing that value into a DB_TIMESTAMP. I was successful when I set the column to type DB_TIMESTAMP2

    Connection Manager, advanced tab

    Demo package available at https://sites.google.com/site/billfellows/home/files/FastParse.dtsx?attredirects=0&d=1

    0 讨论(0)
提交回复
热议问题