date formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi ,
I got a string like "20030101" and I want this to become the date 01 jan 03 . I can't figure it out. Can you please help if this action is possible

Cheers,
Douvid
 
One way:

Select your date string(s). Choose Data/Text to Columns. Click Next,
Next. Select YMD in the date dropdown. Click Finish. Format as a
date.


Note: Your example is ambigouous, so you may need to use YDM instead.
 
Turn on the macro recorder and do it manually. (for Text to columns)

If you are talking about parsing a string (assuming string is yyyymmdd)

Dim dt as Date
Dim sStr as String
sStr = "20030101"
dt = DateValue(Mid(sStr,5,2) & "/" & mid(sStr,7,2) & "/" & Left(sStr,4))

Demo'd from the immediate window:
sStr = "20030101"
? DateValue(Mid(sStr,5,2) & "/" & mid(sStr,7,2) & "/" & Left(sStr,4))
1/1/03
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top