Solved

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

Posted on 2013-01-25
5
825 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

820 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