Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 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: Parsing Non-Standard Date Formats.

Parsing Non-Standard Date Formats

Written by Allen Wyatt (last updated November 22, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

Bill is faced with the challenge of importing data into Excel that was originally created in other applications. The problem is that the data contains lots of dates, but they are in a format that Excel doesn't understand. For instance, the dates may be in the format 09.15.20 or 9.15.2020, neither of which is treated as a date by Excel. Bill wants to know how to convert the non-standard dates to a date format that Excel understands.

If the dates are in the same sequence format that you use in your regional settings, then converting is a snap. For instance, if your regional settings use the date format MDY (month followed by day followed by year), and the date you are importing is in the same format, then you can simply select the cells and replace the periods with a slash. When Excel changes 9.15.2020 to 9/15/2020, it automatically parses the result as a date.

If the format you are importing doesn't match your regional settings, then you need to shuffle around the date into the same format. For instance, if the date you are importing is 09.10.20 (September 10, 2020), and your system would interpret this as October 9, 2020, then the easiest way is to separate the date into individual components, and then put them back together. Follow these general steps:

  1. Insert three blank columns to the right of the date column.
  2. Select the cells containing the non-standard dates.
  3. Using the Text to Columns tool (available in the Data Tools group on the Data tab of the ribbon) choose delimited data and use a period as the delimiter. After the wizard is done, you end up with three columns containing the month, day, and year.
  4. In the remaining blank column, enter a formula such as the following:
  5.      =DATE(C1,A1,B1)
    
  6. Copy the formula down to other cells next to the dates.
  7. Select the cells containing the formulas you just created, then press Ctrl+C.
  8. Use Paste Special to convert the formulas to results. (Select the Values option when using Paste Special.)
  9. Delete the three columns that contain the separated dates and keep the column that contains the final dates.

Another solution is to simply use a macro to do the conversion. The following is a user-defined function that takes the non-standard date and converts it to a properly formatted date value. The macro also switches around the position of the month and day, as done in the Text to Columns technique.

Public Function Convert_Date(A As String) As Date
    Dim K As Long
    Dim K1 As Long
    Dim K2 As Long

    K = Len(A)
    K1 = InStr(1, A, ".")
    K2 = InStr(K1 + 1, A, ".")
    Convert_Date = DateSerial(Val(Mid(A, K2 + 1, _
      K - K2 + 1)), Val(Mid(A, K1 + 1, K2 - K1)), _
      Val(Mid(A, 1, K1 - 1)))
End Function

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9837) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Parsing Non-Standard Date Formats.

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

Quickly Clearing Array Contents

An array of variables is a powerful element of VBA programming. If you want to clear what is stored in an array, here's a ...

Discover More

Conditionally Making a Sound

Need to have a sound played if a certain condition is met? It is rather easy to do if you use a user-defined function to ...

Discover More

Displaying the First Worksheet in a Macro

When creating macros, you often have to know how to display individual worksheets. VBA provides several ways you can ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

ISO Week Numbers in Excel

Work in an industry that uses ISO standards when it comes to working with dates? You'll love the formula in this tip ...

Discover More

Rounding to the Nearest Quarter Hour

When entering times in a worksheet, you may have a need to round whatever you enter to the nearest 15-minute increment. ...

Discover More

Converting Mainframe Date Formats

Different industries and different computer systems specify dates in all sorts of strange ways. If you need to convert a ...

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

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}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. 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 6 - 0?

2020-04-18 23:16:47

Alex B

In scenario where "format you are importing doesn't match your regional settings". The above solution suggests using Text to Columns and a formal.
The text to columns function can do it in one step.
a) Select the Cell or column
b) Text to Columns
c) Delimited - pick something that doesn't exist eg TAB
d) On the next screen select "Date"
e) from the drop down box select the format that the date you are seeing is in
eg in the above example if 09.10.2020 is meant to be October 9, 2020 then the date format you select is DMY
f) select a destination and hit finish
(see Figure 1 below)

The above will also work instead of the replace in the first option is you find it quicker and in fact should be available when you import the data in the first place.

Figure 1. Convert Text to Column


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.