Solved

VBA Date character extraction

Posted on 2006-07-24
6
268 Views
Last Modified: 2008-03-10
Hi

I want to include the date and time of file generation in the file name. How can I keep the mm, dd, yy, hh, mm, ss and delete the characters  / and : from the general format mm/dd/yy hh:mm:ss ?


Thanks,
st
0
Comment
Question by:spacetraveller
  • 3
  • 2
6 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
ID: 17170227
Format(YourDateGoesHere, "mm") & Format(YourDateGoesHere, "dd" & Format(YourDateGoesHere, "yy") & etc. etc.
0
 
LVL 39

Assisted Solution

by:stevbe
stevbe earned 250 total points
ID: 17170269
Public Function MakeFileName(FileName As String, FileExt As String)
    MakeFileName = FileName & Format(Now(), "mmddyyhhnnss") & FileExt
End Funcrion

0
 
LVL 39

Expert Comment

by:stevbe
ID: 17170281
the key part is to not use the seperators in the Format Funtrion ...

Format(Now(), "mmddyyhhnnss")

now add your base filename at the beginning and file extention at the end ... the function I posted makes this a bit easier for me as I have a number of file formats I export to.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 65

Expert Comment

by:Jim Horn
ID: 17170290
Wowwie.  Learn something new every day.
0
 
LVL 39

Expert Comment

by:stevbe
ID: 17170312
I use yyyymmddhhnnss so I can easily sort my files cronologically but that is just me ... format it however you would like :-)
0
 

Author Comment

by:spacetraveller
ID: 17170374
Thanks Jim Horn and Stevbe. now I know that I have to use "Format".

Thanks a lot.

st
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question