Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBA Date character extraction

Posted on 2006-07-24
6
Medium Priority
?
290 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
[X]
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
  • 3
  • 2
6 Comments
 
LVL 66

Accepted Solution

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

Assisted Solution

by:stevbe
stevbe earned 1000 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 66

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

704 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