Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Converting Coded Dates into Real Dates.

Converting Coded Dates into Real Dates

by Allen Wyatt
(last updated May 3, 2016)

8

Luis receives dates in the format "04C13" where the first two digits are the day, the letter in the middle is the month (A is January, B is February, C is March, etc.), and the last two digits are the year. He needs to transform these coded dates into regular date values that he can work with in Excel.

The biggest thing that makes this date format non-standard is the use of the alphabetic character for the month. So, the first thing to do is to figure out how to convert that character into a numeric month. This is where the CODE function can be helpful; it returns the ASCII code for the character. The letter A returns the value 65, B returns 66, and so on. So, all you need to do to convert the letters into the numbers 1 through 12 is to use something like this:

=CODE(UPPER(MID(A1,3,1)))-64

The UPPER function is used to convert the month character to uppercase, just in case the code allows lowercase letters for months.

Another way of converting the months is to use the FIND function, in this manner:

=FIND(UPPER(MID(A1,3,1)),"ABCDEFGHIJKL",1)

This technique finds the character within the alphabetic string and returns the offset within that string, 1 through 12. This approach is best to use if the letters representing the months are not consecutive or if they are a decreasing sequence.

Either method of converting the months can then be used inside a DATE function to return a date based upon a year, month, and day. This example uses the CODE method, but you could just as easily use the FIND method:

=DATE(2000+RIGHT(A1,2),CODE(UPPER(MID(A1,3,1)))-64,LEFT(A1,2))

If there is the possibility that the coded dates could include some dates prior to 2000, then using the DATEVALUE function to put together the date will produce more accurate results:

=DATEVALUE(CODE(UPPER(MID(A1,3,1)))-64&"/"&LEFT(A1,2)&"/"&RIGHT(A1,2))

If you use the DATEVALUE approach, understand that the formula returns a date serial number and that you will need to format the cell to display the date as you would like it displayed.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7014) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Converting Coded Dates into Real Dates.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing Cell Patterns

You can shade your cells by filling them with a pattern. Here's how to select the pattern you want used.

Discover More

Converting to Octal

If you need to do some work in the base-8 numbering system (octal), you'll love two worksheet functions provided by Excel for ...

Discover More

Using RD Fields with Chapter Headings

The RD field can be handy for pulling together a bunch of documents into a single file. However, using the field can play ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

MORE EXCELTIPS (RIBBON)

Returning Nothing If Two Values are Empty

Excel includes a large number of functions that can be used in evaluating the data in a worksheet. In this tip you learn ...

Discover More

Elapsed Days as Years, Months and Days

Need to know how many days there are between two dates? It's easy to figure out—unless you need the figure in years, ...

Discover More

Monthly Close-Out Dates

If your company closes out its accounting months at the end of each calendar quarter, figuring out the proper closing dates ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 3 - 0?

2016-05-05 15:23:27

Michael (Micky) Avidan

@Thomson,
I was only refering to your comment dated: 03 May 2016, 19:28
It is for good practice to "let go" of all the "meanings" within the first comment like a reason for a formula expansion (to handle: JA, FE, MA etc) and not after receiving questions/Wonderings like in my previous comment.
-------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL


2016-05-05 10:46:26

Pancho

Thanks for all the help
I cannot get Allen's DATEVALUE to work it just returns #VALUE!
I have double checked the formatting of the cells and done a formula evaluation - this returns the formula section 'MID(A1,3,1)' italicized
Any ideas as I need to convert coded dates for years 19** and 20**


2016-05-05 00:09:11

Thomson

@Michael

I agree MID is much easier for you and me. However, CHOOSE can be use for double digits and easier for human reading (For person who will use this workbook other than you with just beginner Excel skill)


e.g. I can replace with A-L to the following.

JA
FE
MA
AP
MY
JN
JL
AU
SE
OC
NO
DE


2016-05-04 06:18:52

Pancho

@Thomson
That is extremely helpful
Thankyou very much


2016-05-04 05:21:44

Michael (Micky) Avidan

@Thomson,
Was there a special reason for suggesting a TWICE AS LONG formula section (usage of CHOOSE instead of MID) ?
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL



2016-05-03 19:28:51

Thomson

Or using Choose function instead of MID

=CHOOSE(MONTH(C3),"A","B","C","D","E","F","G","H","I","J","K","L")


2016-05-03 19:25:47

Thomson

Assume your date on A1
=TEXT(A1,"dd")&MID("ABCDEFGHIJKL",MONTH(A1),1)&TEXT(A1,"YY")

Or you can replace MID function to Vlookup table.


2016-05-03 11:30:42

Pancho

That's fine and thanks for the details.
How can I reverse this tip? I want to enter a date that will convert to code (not necessarily in the same cell) For example, if I enter 04-Mar-2013 how can I get that to appear as 04C13?


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing