Hamzah Amir
Hamzah Amir

Reputation: 63

Dynamic file naming with SSIS to include date and time

I want to export multiple files a day so I need my SSIS package to name each file with a unique file name in a CSV format for example exported_09092020_14_25.csv. I found a tutorial online but I am coming across this issue below:

Can someone please help me with this, thank you in advance

  “C:\\TEMP\\SaturnExport\\Exported_” + RIGHT(“0” + (DT_STR,4,1252) DATEPART(“M”,GETDATE()),2)
+ RIGHT(“0” +(DT_STR,4,1252) DATEPART(“DD”,GETDATE()),2)
+ (DT_STR,4,1252) DATEPART(“YYYY”, GETDATE()) +”_” + (DT_STR,2,1252) DATEPART(“HH”,GETDATE()) +”_”
+ (DT_STR,2,1252) DATEPART(“MI”,GETDATE()) + “_”
+ (DT_STR,2,1252) DATEPART(“SS”,GETDATE()) + “.CSV”

A

Upvotes: 0

Views: 597

Answers (1)

Wouter
Wouter

Reputation: 2976

You shouldn't use the curly quotes:

 "C:\\TEMP\\SaturnExport\\Exported_" + RIGHT("0" + (DT_STR,4,1252) DATEPART("M",GETDATE()),2)
+ RIGHT("0" +(DT_STR,4,1252) DATEPART("DD",GETDATE()),2)
+ (DT_STR,4,1252) DATEPART("YYYY", GETDATE()) +"_" + (DT_STR,2,1252) DATEPART("HH",GETDATE()) +"_"
+ (DT_STR,2,1252) DATEPART("MI",GETDATE()) + "_"
+ (DT_STR,2,1252) DATEPART("SS",GETDATE()) + ".CSV"

Upvotes: 1

Related Questions