I have a scenario where I need to create a folder on fly with current date in YYYYMMDD format.
Here is simple solution how we can achieve using Expression Builder in SSIS packages. Pick the variable that’s needs to be configured.
Go to properties of the variable you want to configure and click expression.
A Popup window will appear where you can select the variable you want to configure
Select the property you want to override. For me its Destination path property of the Source folder variable I am using in my package.
C:\Development\XXXXX\XXXXX\20130516\
Here is code that needs to append to the variable. So here is what I have used to get this in below format.
(DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2)
- yyyy – Year
- q – Quarter
- m – Month
- y - Day of year
- d – Day
- w – Weekday
- ww - Week of year
- h – Hour
- n – Minute
- s - Second
Hope this helps!!!