show hours and minutes in filename

  • Thread starter perryclisbee via AccessMonster.com
  • Start date
P

perryclisbee via AccessMonster.com

I am exporting the results of a query into excel, and saving the spreadsheet
as a date/time specific name. Below is the structure I was trying to use:

strFileName = strPath & "SPA_" & "Karla" & "_" & CStr(Format(Date, "mmddyyyy")
) & "_" & CStr(Format(Date, "hhnn")) & ".xls"

All this does is return a saved file that looks like this:
Karla_04172007_0000.
I want the query/export to generate a unique filename each time it exports
and saves, even if it is exported every 10 minutes. Why won't the hours and
minutes (hhnn) show up on the saved name? Any ideas?

thanks,

Perry
 
Z

zh875 via AccessMonster.com

Hi Perry,

I add the following code to append the time to a filename:

newfname = Left$(Time$, 2) & Mid$(Time$, 4, 2) & Right$(Time$, 2)

just append 'newfname' to your filename.

It justs splits out the Hours, Mins and Seconds and adds them to the filename.


With the rest of the code, I have files that can be generated seconds apart
and each one is unique.

If the clever people out there have a simpler way, please let me know.

Regards

Rick
 
B

Brotha Lee

Percy,

Replace the CStr(Format(Date, "hhnn")) with CStr(Format(time, "hhmm")).

HTH
 
J

John Spencer

Format(Now(),"mmddyyyy\_hhnn")

Should create a string with month, day, year, hour and minute.

Date is just the date with the time at midnight. Now is the current
date and time.



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top