When you're creating a flat file, often times you'd like to place a date stamp at the end of the file name in order to show when the file was created simply when sharing the file with a partner. The problem comes in though where you wish to have a two digit date. If you were to create an expression that resembles the following code:
"C:\\Extract" + SUBSTRING((DT_WSTR, 30) GETDATE(),1,10) + ".csv"
The leading zeros in one digit date (ie January with a 01) may yield you the results: C:\Extract2008-2-5.csv (results may vary based on your locale). Your partners may be a frustrated with you when sometimes you send them files with 6 digit dates and other times 8 digit dates since they're trying to automate their processes as well.
The alternative is to first cast the getdate() function into a DT_DBDATE, which only holds the date (stripping the time) and then cast it into a string thereafter.
"C:\\Extract" + (DT_WSTR, 10) (DT_DBDATE) GETDATE() + ".csv"
This will product a predictable format for your flat files of the following:
C:\Extract2008-02-05.csv
-- Brian Knight