Search code examples
sql-servert-sqlssissql-server-2012dataflowtask

How to get last two numbers from year in a variable expression for ssis package?


I am dynamically generating the date for ssis tranformation using variable expression. My below expression generates the output like:

02102014.csv
Expression :
+RIGHT("0" + (DT_WSTR, 2)  MONTH(dateadd("d", -1, getdate())), 2) 
+RIGHT("0" + (DT_WSTR, 2) DAY(dateadd("d", -1, getdate())), 2)
+(DT_WSTR, 4)  YEAR(dateadd("d", -1, getdate()))+ ".csv"

How can I get the value like 021014.csv. In the year string it should pick up only last two values. Can anyone help me?


Solution

  • Expression:

    RIGHT("0" + (DT_WSTR, 2) MONTH(dateadd("d", -1, getdate())), 2) 
    + RIGHT("0" + (DT_WSTR, 2) DAY(dateadd("d", -1, getdate())), 2)
    + RIGHT((DT_WSTR, 4) YEAR(dateadd("d", -1, getdate())), 2)+ ".csv"

    Result:

    021014.csv