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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing date format (VBA Excel)

Status
Not open for further replies.

Elvab

IS-IT--Management
Aug 15, 2005
1
IE
Hi

its been a few years since I have used VBA and am just starting to get back into it so apologies if this question is silly.

I have a column with a date in the format yyyymmdd (eg todays date would appear 20050815)
this data is being imported from another program so cant be changed.
I need this date changed to a different format so it can be used in calculations.

I have used the DATEVALUE command in some of the calculations to get the format that i need.
to get todays date would be =DATEVALUE("15-08-2005")

So my question is how can i break up the value 20050815 to 15-08-2005 ?

Any help or suggestions would be very welcome

Thank you
Elva

 

Hi,

Use DateSerial. Parse your Numeric String into year, month and day.
Code:
MyString = "20040101"
MyDate = DateSerial(left(MyString,4), Mid(MyString,5,2) ,Right(MyString,2))


Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top