Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VBA Date character extraction

Posted on 2006-07-24
6
274 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

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 a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 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