Reputation: 1
I need a SQL job to run every day.
This CSV file needs to be named with yesterday’s date. So, if this job was to run today, it would generate a file called 20160820_invoices.csv.
I use following code but it does not work.
"C:\\Invoices_" + (DT_WSTR,4)DATEPART("yyyy",GetDate()) +
RIGHT("0" + (DT_WSTR,2)DATEPART("mm",GetDate()) ,2) +
RIGHT("0" + (DT_WSTR,2)DATEADD("dd", -1, GetDate()),2) + ".csv"`
Is there any other way I can correct it to get it to work?
Upvotes: 0
Views: 114
Reputation: 416029
"C:\\Invoices_" + CONVERT(varchar(8), DATEADD(d, -1, current_timestamp), 112) + ".csv"
Upvotes: 1