Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple date reformat 1

Status
Not open for further replies.

Yaik

Programmer
Oct 1, 2010
36
US
I have many csv files that look kinda like this

Code:
Inventory Date,Product Name,Version,Install Date,Status,Host Name
12/15/2010,Adobe Acrobat 9 Pro,9.0.0,11/5/2010,Installed,ERM-10162045
12/15/2010,ArcGIS Desktop,9.3.3500,20091217,Installed,ERM-10162045
12/15/2010,Microsoft Access 2002,10.0.2627.01,20091002,Installed,ERM-10162045
12/15/2010,CanVis 2.3,,,Installed,ERM-10162045]

The "Install Date" is picked up directly from the registry, and as you can see, they are not all formated the same.

There are two formats of dates in the registry

yyyymmdd and mm/dd/yyyy

The date format that I would like all of them to be is mm/dd/yyyy

If anybody can help me get a simple script that is able to capture the yyyymmdd format and convert it to mm/dd/yyyy.

Thank you.
 
You may use a function like this:
Code:
Function reformat(ymd)
reformat = Mid(ymd, 5, 2) & "/" & Right(ymd, 2) & "/" & Left(ymd, 4)
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This works great, for the unformatted dates, but when it does it for the already formatted dates, it messes them up. Is there any way to have some kind of IF statement that if the date already includes a "/" to leave it as is, and if it does not contain a "/" to format it.
 
Never mind,I added to IF statement myself and works like a charm. Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top