Datestamp a File Name

M

mcgregor

Is there any way to set a date stamp to a file name? I run the same queries
each morning and would like to send them to a server without overwriting the
previous file. I would like to keep the existing file name but have it add
the date to the name each time the query is run.

Help is appreciated.
 
W

Wayne Morgan

You should be able to concatenate the date into the file name. You have to
remember to not use characters that aren't legal in file names, for example
you would use 2005-08-07 instead of 2005/08/07. I also recommend the
Year-Month-Date format so that when you sort by file name you'll get the
files in chronological order.

How are you currently supplying the file name?

To get the date in the format listed above,
strFileName & Format(Date(), "yyyy-mm-dd") & ".csv" 'or whatever extension
you use.
 
Top