How to process files based on date timestamp in for each loop

  • I am trying to loop reach file in the foreachloop container based on date timestamp

    file names will be

    bookride_190827184345.txt

    bookride_190906173907.txt

    bookride_190906174008.txt

     

    I have an SSIS package where i need to process these files based on date timestamp first loop has to process  bookride_190827184345.txt, next bookride_190906173907.txt last  bookride_190906174008.txt

     

    using script task how to achieve this?

     

  • Wouldn't you declare a variable to hold the filename and then use .NET functions to parse out the chunks you want that make a date? Then compare it to some value to determine what to do with the file?

  • The files all have the same prefix before the time stamp.  That means they'll sort naturally and you don't need to split anything out of the file name to process them in order.

    --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)

  • Unless i recall incorrectly, using a For Each Loop Container on a file directory will process the files in alphabetical order; so there's no need for a script task here.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

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

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