Exporting Excel Files with DateStamp

2 posts / 0 new
Last post
jaz
Offline
Joined: 04/27/2020 - 22:13
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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