Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. 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.
by Allen Wyatt
(last updated November 3, 2018)
Luis receives dates in the format "04C18" 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:
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:
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:
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:
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, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Converting Coded Dates into Real Dates.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Sometimes it is handy to know how many days are left in the current year. This tip provides a quick formula that ...Discover More
If you import information generated on a UNIX system, you may need to figure out how to change the date/time stamps to ...Discover More
Need to figure out if one date is between two other dates? There are a wide variety of formulaic approaches you could use ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.