Dynamic Foreach file location

  • Hey I've an ssis package that deals with many files on a weekly basic. so i drop all of the file into a weekly folder named W01 , W13 etc. but this mean that i have to keep changeing my foreach loop to point at the weekly folder thats created.

    Is there a way that i can do this without having to manually change the foreach to point to the weekly folder.?

    I've created avariable and i've stored the path in the variable.

    example i've stored this path \et\loc\files

    I was trying to use the expression in the foreach to sent the property of the option directory to be the variable +'W'+ datepart(wk,getdate())

    so it would give me \et\loc\files\W13

    but i can't get the expression to work.

  • Try this

    "\et\loc\files\W"+ (DT_STR, 200, 1252) DATEPART( "wk", GETDATE() )

  • Correction!

    "\\et\\loc\\files\\W"+ (DT_STR, 200, 1252) DATEPART( "wk", GETDATE() )

  • this worked for me thanks , but can i use the getdate()-1 in the expression ? i need to use the -1 to look for the folder for the pervious week..

  • Yes, that should work. I do not know exactly how it defines week of the year (does it begin on a Sunday or the day Jan 1 lands on, for example) so you may need to do some experimenting.

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

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