Expression Schooling
Hello, I’m having a little trouble getting an expression to work properly for an SSIS package and hoping someone can school me on what I need to do. I have a vendor that places zip files on their FTP site for us to import. The zip files are for the following month. For example I was made aware on 12/28 the file BURU1101.zip was available for me to get. This is our 2011 Jan file which I need to get. Below is what I have so far but I’m unsure how to add the logic for what I need to do. "\\BURU" + DATEADD( «datepart», «number», «date» ) + (LEN((DT_STR, 2, 1252) MONTH( GETDATE() ) ) == 1 ? ("0" + (DT_STR, 2, 1252) MONTH( GETDATE() ) ) : (DT_STR, 2, 1252) MONTH( GETDATE() ) ) + ".zip" Any input to help a noob out is appreciated! Thanks
December 29th, 2010 8:32am

Is the logic as follows: Next file is expected in Jan 2011 (say on Jan 18) and its name will be BURU1102.zip? If yes, then expression "\\" + "\\BURU" + RIGHT("0" + (DT_WSTR,4)YEAR(DATEADD( "yy", 1, GETDATE() )), 2) + RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD( "mm", 1, GETDATE() )), 2) + ".zip" will work for files in Dec and you do not need to increment year/month for other months.Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
December 29th, 2010 9:29am

Is the logic as follows: Next file is expected in Jan 2011 (say on Jan 18) and its name will be BURU1102.zip? If yes, then expression "\\" + "\\BURU" + RIGHT("0" + (DT_WSTR,4)YEAR(DATEADD( "yy", 1, GETDATE() )), 2) + RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD( "mm", 1, GETDATE() )), 2) + ".zip" will work for files in Dec and you do not need to increment year/month for other months. Arthur My Blog Sorry I should have explained more clearly. The monthly files will go like this. Dec 2010- expected filename-> BUR1101.zip Jan 2011 expected filename - > BUR1102.zip Feb 2011 expected filename -> BUR1103.zip March 2011 expected filename -> BUR1104.zip So the files will be named based on the following months date.
December 29th, 2010 9:51am

ArthurZ has the right script, but you do not need to add a string zero to the year and you want to increment the year and month by one month. So it would look like this. "\\" + "\\BURU" +Right( (DT_WSTR,4)YEAR(DATEADD( "mm", 1, GETDATE() )),2) + RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD( "mm", 1, GETDATE() )), 2) + ".zip" Mike Davis, MCTS, MCITP
Free Windows Admin Tool Kit Click here and download it now
December 29th, 2010 9:52am

That worked!! Thank you both so much for your input!
December 29th, 2010 9:57am

My script should work (with the modification proposed by Mike Davis), you just need to branch the logic. The below is good for months other than Dec: "\\" + "\\BURU" +Right( (DT_WSTR,4)YEAR(DATEADD( "yy", 0, GETDATE() )),2) + RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD( "mm", 1, GETDATE() )), 2) + ".zip" To branch you can use (DT_WSTR,2)MONTH(GETDATE()) to see if the month is 12 (December).Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
December 29th, 2010 10:00am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics