convert date from string to date format

  • Thread starter Howard - JC Publishing
  • Start date
H

Howard - JC Publishing

I am importing data from our database into Excel. The database program
stores dates as a string such as 20080124. I want to convert that string the
mm/dd/yyyy.

Thank you.
 
T

timmg

I am importing data from our database into Excel.  The database program
stores dates as a string such as 20080124.  I want to convert that string the
mm/dd/yyyy.

Thank you.

Assuming the value in A1 the formulae:

=MID(A1,5,2)&"/"&RIGHT(A1,2) &"/" &LEFT(A1,4) will produce a text
value

and

=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2)) will produce a date that can
be formatted to what you want
 
R

Ron Rosenfeld

I am importing data from our database into Excel. The database program
stores dates as a string such as 20080124. I want to convert that string the
mm/dd/yyyy.

Thank you.

First convert it to a real Excel date:

=DATE(INT(A1/10^4),MOD(INT(A1/10^2),100),MOD(A1,100))

Then, either format the cell as you wish, or use the TEXT function:

=TEXT(DATE(INT(A1/10^4),MOD(INT(A1/10^2),100),MOD(A1,100)),"mm/dd/yyyy")

--ron
 
G

Gord Dibben

Data>Text to columns>Next>Next>Column Data Format>Date>YMD and Finish


Gord Dibben MS Excel MVP
 

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

Top