Archive

Archive for November, 2021

Adding _YYYYMMDD or _YYYYMMDD_HH24MISS suffix to source or destination output files

November 3, 2021 Leave a comment

Whenever you need to either load data from source or direct your output to file(s) with date/datetime suffix derivable from the date in the form of YYYY MM DD or YYYY MM DD HH24 MI SS

so it’s changing constantly, one of the possible ways to go with is SSIS expressions by creating SSIS variable of string type

and set it to

“_” + (DT_WSTR,4)YEAR(GETDATE()) + RIGHT(“0” + (DT_WSTR,2)MONTH(GETDATE()), 2) + RIGHT(“0” + (DT_WSTR,2)DAY( GETDATE()), 2)

for _YYYMMDD suffix layout

or

“_” + (DT_WSTR,4)YEAR(GETDATE())+ RIGHT(“0” + (DT_WSTR,2)MONTH(GETDATE()), 2)+ RIGHT(“0” + (DT_WSTR,2)DAY( GETDATE()), 2) + “_” + RIGHT(“0” + (DT_WSTR,2)DATEPART(“hh”, GETDATE()), 2) + RIGHT(“0” + (DT_WSTR,2)DATEPART(“mi”, GETDATE()), 2) + RIGHT(“0” + (DT_WSTR,2)DATEPART(“ss”, GETDATE()), 2)

for _YYYYMMDD_HH24MISS suffix layout like in this specific example

after that the only thing remaining is to change the flat file connection manager to the respective expression using that variable

Categories: SSIS