Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Dates Won't Sort in Excel: How to Fix Formatting Issues

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Dates won't sort in Excel because the software perceives them as text strings rather than numerical date values. To fix this, you must convert the cells from 'Text' format to 'Date' format using the Text-to-Columns tool or the VALUE function, ensuring Excel recognizes the underlying serial number it uses to track time.

What You'll Need

  • A computer with Microsoft Excel installed.
  • The dataset containing the dates that are refusing to sort.
  • Administrative permissions to edit the spreadsheet.

Step-by-Step

Depending on how the data was imported (e.g., from a CSV, a web scrape, or manual entry), the solution varies. Labels and menu paths may differ slightly depending on your version of Excel or region.

Method 1: Using Text-to-Columns (The Fastest Fix)

This is the most effective method for fixing an entire column of dates that are formatted as text.

  1. Select the column containing the problematic dates by clicking the letter header at the top of the column.
  2. Go to the Data tab on the top ribbon.
  3. Click on the Text to Columns button located in the Data Tools group.
  4. In the Convert Text to Columns Wizard, select Delimited and click Next.
  5. Uncheck all delimiters (such as Tab, Semicolon, Comma) so that no splitting occurs. Click Next.
  6. In the Column data format section, select the Date radio button.
  7. From the dropdown menu next to 'Date', select the format that matches how your dates are currently written (e.g., MDY for Month-Day-Year or DMY for Day-Month-Year). This tells Excel how to read the existing text.
  8. Click Finish. Your dates should now align to the right of the cell, indicating they are recognized as numbers.
  9. Now, click the filter arrow in the header and select Sort Oldest to Newest or Sort Newest to Oldest.

Method 2: Using the VALUE Function

If you prefer to keep your original data intact and create a corrected column next to it, use a formula.

  1. Insert a new blank column next to your date column.
  2. In the first cell of the new column, type =VALUE(A2) (assuming A2 is the cell with the text-date).
  3. Press Enter. You will likely see a five-digit number (e.g., 45230). This is Excel's internal serial number for that date.
  4. Click and drag the fill handle (the small square at the bottom-right of the cell) down to apply the formula to the rest of the column.
  5. With the new column still selected, go to the Home tab.
  6. In the Number group, click the dropdown menu (which likely says 'General') and select Short Date.
  7. You can now sort by this new column, or copy the results and use Paste Special > Values to overwrite the original text-dates.

Method 3: Forcing a Format Change with Paste Special

Sometimes cells are stuck in 'Text' mode even after you change the format dropdown. This trick forces Excel to re-evaluate the cell contents.

  1. Find an empty cell anywhere in your workbook and type the number 1.
  2. Right-click that cell and select Copy.
  3. Highlight the range of dates that won't sort.
  4. Right-click the highlighted area and select Paste Special....
  5. In the dialog box, under the 'Operation' section, select Multiply.
  6. Click OK. This multiplies every 'text' date by 1, which forces Excel to convert the text to a number.
  7. Change the cell format back to Date via the Home tab dropdown.

Common Mistakes

Many users attempt to fix sorting issues by simply changing the format in the dropdown menu. However, changing a cell from 'Text' to 'Date' via the Home tab does not actually change the data already inside the cell; it only changes how future data entered into that cell will be treated. You must perform an action (like the Text-to-Columns method) that forces Excel to re-parse the existing content.

Another common error is ignoring leading or trailing spaces. If a date is entered as " 01/01/2023" (with a space at the start), Excel will treat it as text regardless of the format settings. Using the TRIM function can resolve this before attempting to sort.

Users also frequently confuse the 'Sort' function with 'Filter'. Filtering allows you to see specific dates, but sorting arranges them. If your filter dropdown shows a list of individual dates rather than grouped years and months, it is a definitive sign that Excel thinks your dates are text.

Tips

To prevent this issue in the future, always ensure your cells are formatted as 'Date' before you import or type data. If you are importing from a CSV, use the Get Data > From Text/CSV feature in the Data tab. This opens the Power Query editor, which allows you to explicitly set the data type of each column before the data ever hits your spreadsheet.

Use the =ISNUMBER() formula to quickly audit your data. If you type =ISNUMBER(A2) and it returns FALSE for a cell that looks like a date, that cell is stored as text and will not sort correctly. This is the fastest way to identify exactly which rows are causing the sorting failure in a massive dataset.

Consistency is key. Avoid mixing date formats (e.g., using 01/02/2023 and 2-Feb-23 in the same column). While Excel can often handle this, it increases the risk of the software defaulting to text format during a bulk import.

Troubleshooting

If the steps above did not work, try these checks in order of complexity:

  1. Check for Hidden Characters: Sometimes data imported from the web contains non-breaking spaces. Use the formula =SUBSTITUTE(A2, CHAR(160), "") to remove these invisible characters, then try the Text-to-Columns method again.
  2. Verify Regional Settings: If your computer is set to US English (MDY) but the data is in UK format (DMY), Excel may fail to recognize the dates entirely. Check your system settings in the Windows Control Panel under Region or change the date format specifically within the Text-to-Columns wizard.
  3. Clear All Formatting: Select the column, go to the Home tab, click Clear (the eraser icon), and select Clear Formats. Then, re-apply the Date format and try sorting.
  4. Check for Mixed Data Types: A single text entry in a column of dates can sometimes confuse the sort logic or lead you to believe the dates are text when only a few are.

Frequently Asked Questions

Why does my sort show 1, 10, 11, 2, 20 instead of 1, 2, 10?

This is called alphabetical (or lexicographical) sorting. It happens because Excel treats the dates as text. In a text sort, "10" comes before "2" because the first character "1" comes before "2". Converting the cells to actual Date values will fix this.

Will converting dates to numbers delete my data?

No. Excel stores all dates as numbers (the number of days since January 1, 1900). When you see a date like 01/01/2024, Excel is actually seeing the number 45292. Changing the format only changes the "mask" you see; the underlying data remains the same.

Can I fix this using a Macro or VBA?

Yes, but it is usually unnecessary. For most users, the Text-to-Columns method is faster than writing and debugging a script. If you have thousands of sheets, a VBA script using the CDate() function can automate the conversion.

Why are some dates aligned left and some aligned right?

By default, Excel aligns text to the left and numbers (including dates) to the right. If your column has a mix of alignments, you have a "dirty" dataset where some entries are recognized as dates and others are recognized as text.

Does the 'Date' format in the Home tab fix existing text?

No. Selecting 'Date' from the dropdown only affects how new data is entered. To fix existing data, you must trigger a recalculation using a method like Text-to-Columns, a formula, or the Paste Special multiply trick.