Add "Date" to file name

Robert Schumann
Robert Schumann used Ask the Experts™
on
Hi, using the following cmd in a form.

DoCmd.TransferSpreadsheet acExport, 10, "data", "d:\data\ArdFlashData.xlsx", True

Would like to add the date in the file name

example  ArdFlashData_01/02/2016.xlsx

Not sure how to incorporate    =NOW()  so it will show the date in the file name.

Thanks
Bob
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012
Commented:
DoCmd.TransferSpreadsheet acExport, 10, "data", "d:\data\ArdFlashData_" & Format$(Now(),"mm/dd/yyyy") & ".xlsx", True

Jim.
Robert SchumannFacilities Planner

Author

Commented:
Works Great!!

Just had to remove the "/" in the date format.  Replaced with a "-"

Thank you!!
Robert SchumannFacilities Planner

Author

Commented:
Thanks for the quick replay and great solution!
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Distinguished Expert 2017

Commented:
When I append dates to file names, I prefer to use yyyymmdd order for the date parts so the files will sort correctly in chronological order.
Robert SchumannFacilities Planner

Author

Commented:
Good point.

I was also trying to add the time in addition to the date.  Can't seem to get it to work.

ie:    2016-01-24  14:25:26

Any suggestion?
Distinguished Expert 2017

Commented:
call me a fuddy duddy but I really hate to see embedded spaces and special characters in file names.

format(now(), "yyyymmdd_hhnnss")

The Format() function is your friend.  It would help you to look it up in help and read about what it can do to dates and numbers.
Robert SchumannFacilities Planner

Author

Commented:
Agree.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial