Sorting data by date seems like it should be a simple task, and, indeed, Microsoft Excel offers a number of ways to sort data by date. However, sometimes Excel’s sorting tools don’t work correctly, and that can be very frustrating.
Here are a few ways to sort by date in Excel, as well as a trick to try if dates aren’t sorting correctly.
Contents
Sorting a Single Column of Dates in Excel
The easiest way to sort dates in Excel is to use the sorting tool to display dates in the order you want.
- Select the column of dates by clicking on the column header. In the image below, we have selected the column by clicking on column header A.
- You can also just select the specific cells in the column that have dates in them.
- With your data selected, choose Sort & Filter from the Home menu.
- Now choose either Sort Oldest to Newest or Sort Newest to Oldest. In the example below, we’ve sorted from newest to oldest. Notice that Excel doesn’t change the format of the dates but does correctly sort the dates beginning with the newest.
This method should work in the vast majority of use cases.
Sorting an Entire Worksheet by Date in Excel
If your table has more than one column of data, you’ll want to preserve the relationships between columns when you sort. Below you can see dates in column A and corresponding text in column B.
If you use the method above, (i.e., selecting only the date cells or the whole column of dates, clicking on the Sort & Filter button, and choosing to either Sort Oldest to Newest or Sort Newest to Oldest), Excel will display a Sort Warning and will ask you if you want to expand the selection to include both columns of data.
Make sure that Expand the selection is selected and click the Sort button. Excel will sort all the data in the table in the sort order you selected.
You can see that now all our dates are sorted from oldest to newest, and the relationship between the dates in Column A and the text in Column B has been preserved.
Sorting by Month, Year, or Month and Day in Excel
What if you want to sort by date in Excel by a specific part of the date like month or year?
Sorting Dates by Month in Excel
In our example table of people’s birthdays, for example, you might want to know who was born in each month, ignoring the year each person was born. You can’t use Excel’s regular sort feature because it will always include the year in its sorting algorithm.
To get around this, you can create a helper column that extracts the month so you can then sort by that column. To extract a month from a date, you can use Excel’s MONTH function.
- Create a new column
- In the first cell of the new column, enter =MONTH(A1) where A1 is the cell from which you want to extract the month.
- Repeat step 2 for each row. Excel will extract the month from each of the dates, leaving you with a column of month numbers.
- Now you can sort the table by the column with month numbers. In this case, you’ll sort by column C. If you only select the data in Column C, you’ll get Excel’s Sort Warning again. Choose to Expand the selection and Sort.
Sorting Dates by Year in Excel
If you want to extract the year instead of the month, you can use the steps above, replacing the MONTH function with =YEAR(A1) where A1 is the cell with the date from which you want to extract the year.
Sorting Dates by Month and Day in Excel
Perhaps you want to create a sorted list of birthdays by month and day, ignoring the year. To extract the month and day from the column of dates, we can use Excel’s TEXT function, which converts dates into text. We’ll use the format mm.dd. Follow the steps above, replacing the MONTH function with this formula: =TEXT (A1, “mm.dd”).
Now you can sort by Column C to get a list of everyone’s birthdays by month and day.
Troubleshooting Date Formats in Excel
Sometimes when you try to sort by date in Excel, you might find that you can’t get Excel to recognize data as a date. Imagine, for example, someone gives you a spreadsheet that includes dates. You’ve put the data into Excel, but it isn’t sorting correctly when you try the methods above. Why isn’t it working?
Consider this list of dates:
It looks simple enough. However, when you select the data, press the Sort & Filter button, and opt to sort from Oldest to Newest, it doesn’t work! You might end up with something like this:
Notice that the last date in the column hasn’t been sorted correctly. What on earth is going on?
Chances are that even though the data in cell A9 looks like a date, it isn’t really formatted as a date, so Excel can’t sort it correctly. Depending on which version of Excel you’re using, even if you format the errant cell as a date by selecting the cell, right-clicking and selecting Format Cells and choosing the Date option, that still won’t fix the problem.
How to Fix Dates That Won’t Sort Correctly in Excel
Fortunately, this problem is easy to fix.
- Cut the column of dates by selecting the cells and pressing Ctrl+x, selecting Cut from the Home menu, or right-clicking on the cell(s) and choosing Cut.
- Open Notepad or another plain text editor.
- Paste the dates into the text editor.
- Go back to Excel, select the column the dates used to be in, right-click and select Format Cells.
- Choose Date and click OK.
- Now go back to the text editor and select and copy the list of dates.
- Go back to Excel and paste the dates into the column you formatted in step 5.
- Now you should be able to sort. Select the columns with data, press the Sort & Filter button, and choose Sort Oldest to Newest. Viola! It works!
Other Sorting and Filtering Techniques in Excel
Now that you’ve learned how to sort by date in Excel, you might want to explore other ways to sort and filter your data. These articles will teach you basic one-column and multi-column data sorting, how to alphabetize in Excel, and how to filter data in Excel.