Sorting Dates and Times

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


1

Shelby has a worksheet that contains project information. Among other things, the worksheet contains a date and time in column A. She would like to sort the projects in the worksheet based on this date and time, but when she sorts the information the projects don't show in chronological order. She wonders why this is occurring.

Normally this occurs because the dates and times in column A aren't really stored, internally, in Excel's date and time format. Perhaps they were entered into a column that was previously formatted as text, or perhaps they were imported from an external source and Excel couldn't recognize them as dates.

There are a couple of easy ways to check whether Excel thinks those cells are dates. First, just select one of the dates in column A and then look at the Home tab of the ribbon. If Excel thinks it is a date, there is a very good chance that the Number Format drop-down list (in the Number group) will say "Date." If it says any other format, then chances are that Excel doesn't recognize it as a date.

You can also select the data that needs to be sorted and display the Sort dialog box. In that dialog box, indicate that you want to sort by Column A. If Excel recognizes the column as containing dates, then the Order drop-down list will change to "Oldest to Newest." If it is recognized as something else, it will show as "A to Z" (for text) or "Smallest to Largest" (for numeric values). When you are done checking, press Esc to close the Sort dialog box without actually sorting.

Finally, another way you can check is to use this formula:

=ISTEXT(A1)

Copy the formula down as many rows as necessary, and any result that shows TRUE is indicating a date, in column A, that Excel thinks is really text.

If you determine that the dates in column A are not being stored as dates, then you need to get them converted. There are numerous ways to do this, depending on what is actually stopping Excel from seeing the dates as dates. For instance, if the cells have a leading space in them, then you need to get rid of that leading space. If the dates are notated in a format that Excel doesn't think is a real data format (such as with periods between date elements), then you need to create a formula that picks the desired parts from the date and constructs a date that Excel can understand.

This will obviously take some experimentation, as the number of ways that dates can be displayed in non-date format are legion. Once the conversion to date format is finished, however, you should be able to sort them in chronological order with absolutely no problem.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5678) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

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

Creating Custom Document Properties

Word allows you to keep track of any number of custom properties about a document. Here's how to create those properties ...

Discover More

Selecting a Table

There are several different ways you can select an entire table in Word. The various methods and shortcuts are described ...

Discover More

Zooming In On Your Worksheet

If you have trouble seeing the information presented in a worksheet, you can use Excel's zooming capabilities to ease the ...

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)

Storing Sorting Criteria

Need to do the same sorting operation over and over again? Excel doesn't provide a way to save your sorting criteria, but ...

Discover More

Sorting while Ignoring Leading Characters

Want to ignore some characters at the beginning of each cell when sorting? The easiest way is to simply create other ...

Discover More

Sorting Text as Numbers

When you are sorting by text values, Excel can be very literal, which may not get you the sorting that you want. This tip ...

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 two less than 9?

2023-09-24 11:51:29

J. Woolley

If column A has date/time values as text or a mixture of text and date serial numbers, you might be able to convert all to date serial numbers as follows:
1. Select the cells
2. Pick Data > Data Tools > Text to Columns (Alt+A+E)
3. In the Text to Columns Wizard:
3.a. Pick Delimited, then click Next
3.b. Clear all delimiters, then click Next
3.c. Pick Date for column data format, then click Finish

Alternatively, you might use the Wizard to separate date/time text values into MM DD YY hh mm ss, then re-combine them into date serial numbers using Excel's DATE and TIME functions.


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.