Variable to generate previous data in ssis package?

I created a variable that will check the current date, how can I get the previous date using the expression below?

"/Report-"+(DT_WSTR,4)YEAR(GETDATE())
+ RIGHT("0"+(DT_WSTR, 2) MONTH(GETDATE()) ,2)
+ RIGHT("0"+(DT_WSTR, 2) DAY(GETDATE()) ,2)+ ".csv"

Result:
/Report-20140210.csv

How can I get if I need a previous date

/Report-20140209.csv
+3
source share
2 answers

You will need to apply the dateadd expression to GetDate, indicating that you want to subtract one day.

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

Output /Report-20140209.csv

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

All Articles