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: Converting an Unsupported Date Format.

Converting an Unsupported Date Format

Written by Allen Wyatt (last updated April 24, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

It is not uncommon to load information from other programs into Excel. For instance, you may have data generated by another program, and you want to analyze that data in Excel. When you import data into Excel, it does a fairly good job of assigning the proper data types to information, and it can even parse and convert some data.

When it comes to dates and times, however, not all programs speak in a way that Excel can understand. For instance, if your other program stores dates in the format "Mon Jan 13 14:33:03 2011", then Excel won't be able to parse the date and you will need to do the conversion in some other manner.

Fortunately, most programs generate their dates and times in a format that follows a pattern. Assuming, for instance, that "Mon Jan 13 14:33:03 2001" represents the format followed by all dates, you can do the conversion using a simple formula:

=DATEVALUE(MID(A1,9,2)&MID(A1,5,3)&RIGHT(A1,4)) + TIMEVALUE(MID(A1,12,8))

This formula assumes that the foreign date/time format is in cell A1. Simply format the result of the formula using one of Excel's date/time formats, and you'll have no problem.

If you prefer, you can use the Text to Columns function to break the foreign date/time format into its integral parts:

  1. Make sure there are four empty columns to the right of the date/time. This is where Excel will place the various parts of the date/time.
  2. Choose all of the cells containing the foreign dates/times.
  3. Display the Data tab of the ribbon.
  4. Click the Text to Columns tool in the Data Tools group. Excel starts the Convert Text to Columns Wizard. (See Figure 1.)
  5. Figure 1. The Convert Text to Columns Wizard.

  6. Make sure that Delimited is selected, then click Next. Excel displays the second step of the wizard.
  7. Make sure the Space check box is selected.
  8. Click Finish.

The dates and times are now separated into five individual columns. You can now use a formula to put a valid date/time back together. For instance, assuming that the exploded version of the date/time is in cells A1:E1, you could use the following:

=(C1&B1&E1)+D2

Again, format the result using a date/time format, and you are all set.

If you prefer to use a macro to do the conversion, then the following macro will step through all the selected cells and do the conversion:

Sub ConvDate()
    Dim c As Range
    
    For Each c In Selection.Cells
        c = DateValue(Mid(c, 5, 6) & ", " _
          & Mid(c, 21, 4)) + TimeValue(Mid(c, 12, 8))
        c.NumberFormat = "dd MMMM yyyy h:mm:ss"
    Next c
End Sub

The macro converts the text string to an acceptable date/time (using DateValue) and then formats the cell to display the value property.

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 (9779) 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: Converting an Unsupported Date Format.

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

Finding the Previous Occurrence

Using Word's Object Browser, it is very easy to move among different instances of what you want to search in your ...

Discover More

Taking a Picture

Excel allows you to capture portions of your worksheet as a picture that you can then use in a variety of other ways. ...

Discover More

Hiding a Hyperlink on a Printout

Hyperlinks can be real handy in a workbook, but you may not always want them visible when you send the workbook to the ...

Discover More

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!

More ExcelTips (ribbon)

Adding Ordinal Notation to Dates

Want to add an ordinal suffix to a number, as in 2nd, 3rd, or 4th? Excel doesn't provide a way to do it automatically, ...

Discover More

Calculating a Date Five Days before the First Business Day

Excel allows you to perform all sorts of calculations using dates. A good example of this is using a formula to figure ...

Discover More

Calculating Months for Billing Purposes

Different businesses have different ways to calculate elapsed time for billing purposes. Figuring out a formula that ...

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 2 + 8?

2021-04-26 03:05:34

Mark Galloway

Shouldn't the formula "=(C1&B1&E1)+D2" be "=(C1&B1&E1)+D1" ?


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.