Solved

Need excel formula to convert a non-standard date format to another format

Posted on 2013-01-25
5
779 Views
Last Modified: 2013-01-25
Hello

I have a column of "dates" that are in this format:

Mar-11-1969  
Mar-07-2002  
Mar-21-1999  

I am looking for a formula that will change the date to (in bold)

Mar-11-1969  031169   (MMDDYY)
Mar-07-2002  030702   (MMDDYY)
Mar-21-1999  032199   (MMDDYY)

On a side note:  I have found that when I convert excel files with dates that start with a leading zero (as in 03) Excel will strip the leading zero from the date when exporting to a csv format.   (I don't need date format, so if there is another format that will NOT strip out the leading zero  (when exporting to csv) that would be great.)

Note:  FYI Next month I will have a similar column that has this date format:
Apr-21-1999

So in the formula you give me I will replace the Mar with Apr.

Hmmm... As I prepare this question, I am thinking it is a pretty simple question --  and it will expose me for the Excel ignoramus I am.  

Rowby
0
Comment
Question by:Rowby Goren
  • 2
  • 2
5 Comments
 
LVL 24

Accepted Solution

by:
Steve earned 465 total points
ID: 38820554
with the date in A1 the following formula should work:

=DATEVALUE(MID(A1,FIND("-",A1)+1,2) & " " & LEFT(A1,FIND("-",A1)-1) & " " & RIGHT(A1,4))

then use =TEXT(B1,"mmddyy") to get to the desired format :)

Single formula:
=TEXT(DATEVALUE(MID(A1,FIND("-",A1)+1,2) & " " & LEFT(A1,FIND("-",A1)-1)& " " &RIGHT(A1,4)),"mmddyy")
Date-example.xlsx
Date-example.xlsx
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 38820692
Works great.   Just wondering how does the formula know it's Apr or Mar (or Jun) for that matter.  Are 3 letter Months "Apr" and "Mar" a "standard" excel "parameter"?

Rowby
0
 
LVL 24

Expert Comment

by:Steve
ID: 38820753
The formula converts your date to a more Excel freindly text string "dd mmm yyyy" where it can recognise the month as it is between a two digit and 4 digit number.
Then is just about re-formatting that back the way you want.

Excel will recognise 12 May 2010... but not May 12 2010... :)
0
 
LVL 50

Assisted Solution

by:barry houdini
barry houdini earned 35 total points
ID: 38820912
>Excel will recognise 12 May 2010... but not May 12 2010

so you can use this formula to switch from one to the other and then do that conversion, i.e.

=TEXT(REPLACE(MID(A1,5,7),4,0,LEFT(A1,4)),"mmddyy")

or you can just extract the relevant elements directly like this

=TEXT(1&LEFT(A1,3),"mm")&MID(A1,5,2)&RIGHT(A1,2)

both should produce the required results

regards, barry
0
 
LVL 9

Author Closing Comment

by:Rowby Goren
ID: 38820922
Thanks The_Barman and barryhoudini.  

For the solution and the explanations.  

Rowby
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now