Skip to main content

Exporting Excel Files with DateStamp

Hi can anyone help to guide me to modify the below export script so that i can export my excel with the datestamp everytime i run it? Thank you!
i.e.
if I run it today, the output file will be 18. Duplicate Payment Month 280420.xlsx
if i run it tomorrow it will be 18. Duplicate Payment Month 290420.xlsx
Script:
 Set db = Client.OpenDatabase("Check Against DatabaseM.IMD") Set task = db.ExportDatabase dbname = "Exports.ILB\18. Duplicate Payment Month.xlsx" task.IncludeAllFields eqn = "" task.PerformTask dbname , "Database", "XLSX", 1, db.Count, eqn db.Close Set db = Nothing Set task = Nothing

Brian Element Tue, 04/28/2020 - 05:16

Hi Jaz,

You can use the Now() to get the current date and the Format() to format the date in the way you want.  So your code would look like this.


Set db = Client.OpenDatabase("Check Against DatabaseM.IMD") 
Set task = db.ExportDatabase 
sDate = Format(Now(), "YYYYMMDD")
dbname = "Exports.ILB\18. Duplicate Payment Month " & sDate & ".xlsx" 
task.IncludeAllFields 
eqn = "" 
task.PerformTask dbname , "Database", "XLSX", 1, db.Count, eqn 
db.Close 
Set db = Nothing 
Set task = Nothing

 

The website encountered an unexpected error. Try again later.