Link to home
Start Free TrialLog in
Avatar of spacetraveller
spacetraveller

asked on

VBA Date character extraction

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
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stevbe
stevbe

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.
Wowwie.  Learn something new every day.
I use yyyymmddhhnnss so I can easily sort my files cronologically but that is just me ... format it however you would like :-)
Avatar of spacetraveller

ASKER

Thanks Jim Horn and Stevbe. now I know that I have to use "Format".

Thanks a lot.

st