Excel Practice Test

โ–ถ

How Excel Actually Stores Dates โ€” and Why It Matters for Sorting

Here's something most people don't realize: Excel doesn't store dates as "January 15, 2024" or "15/01/2024." It stores them as plain numbers โ€” called serial numbers. January 1, 1900 is serial number 1. January 1, 2024 is serial number 45,292. Every day is just one number higher than the previous. That's it.

This design is what makes sorting dates so powerful. When your dates are real Excel dates, sorting them is no different from sorting any other number column โ€” Excel lines up the serial numbers in order, lowest to highest or highest to lowest, and you get your dates in perfect chronological sequence. It works instantly, every time.

The problem? Not every value that looks like a date in your spreadsheet is actually stored as a date. If you import data from a CSV, copy from a web page, or receive a file from an external system, those values might be stored as text strings. "01/15/2024" typed as text and "01/15/2024" stored as a real Excel date look identical on screen โ€” but only one of them will sort correctly.

Understanding the difference isn't just academic. When you sort real Excel dates, they always go in the right order because you're really sorting numbers. When you sort text that looks like dates, Excel falls back to alphabetical sorting โ€” character by character, left to right. That's why you sometimes see 2023 dates appearing after 2024 dates, or months out of order. The dates look right but they're not behaving like dates at all.

You can also bookmark our excel reference for shortcuts and formulas you'll use every day. And if you want a broader overview of all sorting types, the how to sort by date in Excel article covers the full landscape โ€” this guide goes deeper on the date-specific issues.

Basic sort: Select your date column โ†’ Data tab โ†’ Sort Oldest to Newest (or use the Aโ†’Z button). For newest first, click Sort Newest to Oldest.

Dates not sorting correctly? They're almost certainly stored as text, not real date values. The giveaway: dates are left-aligned in the cell instead of right-aligned. Fix with Data โ†’ Text to Columns โ†’ Finish to convert them to real dates, then sort again.

Excel Date Sorting: Four Key Scenarios

๐Ÿ”ด Basic Date Sort

Sort a date column from oldest to newest or newest to oldest in seconds.

  • Method: Data tab โ†’ Sort Oldest to Newest
  • Shortcut: Alt+A+S+A (oldest first)
  • Works When: Dates are stored as real Excel dates (right-aligned)
  • Result: Chronological order, all rows move together
๐ŸŸ  Sort Newest to Oldest

Put the most recent dates at the top โ€” common for logs, transactions, and timelines.

  • Method: Data tab โ†’ Sort Newest to Oldest
  • Shortcut: Alt+A+S+D (newest first)
  • Use Case: Sales logs, activity feeds, date-stamped records
  • Tip: Click dropdown arrow in a Table for one-click access
๐ŸŸก Fix Text Dates

When dates look right but sort wrong, they're stored as text. Two ways to fix it.

  • Quick Fix: Data โ†’ Text to Columns โ†’ Finish
  • Formula Fix: =DATEVALUE(A1) converts text to serial number
  • Sign of Text Date: Left-aligned in cell, ISNUMBER returns FALSE
  • After Fix: Paste as values, then sort normally
๐ŸŸข Sort by Month or Weekday

Extract just the month or day-of-week with a helper column, then sort by that.

  • Month Sort: =MONTH(A1) โ†’ sort helper column 1โ€“12
  • Weekday Sort: =WEEKDAY(A1) โ†’ sort helper column 1โ€“7
  • Dynamic (Excel 365): =SORT(A2:B10, 1, 1) โ€” no helper needed
  • After Sort: Delete helper column or hide it

Basic Date Sort โ€” Step by Step

If your dates are stored correctly as Excel date values, sorting them is genuinely straightforward. Here's exactly how to do it.

Method 1: The Data Tab

Click any cell inside your date column โ€” you don't need to select the whole column. Then go to the Data tab in the ribbon. You'll see two buttons in the Sort & Filter group: Sort Oldest to Newest (Aโ†’Z with a calendar icon) and Sort Newest to Oldest (Zโ†’A icon). Click the one you want.

If your data has multiple columns, Excel will ask whether to expand the selection (sort all columns together, keeping each row intact) or continue with only the date column. Always choose Expand the selection โ€” sorting just the date column scrambles the rest of your data. After sorting, scan the first few rows to verify the order makes sense.

Keyboard Shortcuts for Date Sorting

No mouse needed. Place your cursor anywhere in the date column, then press each key in sequence:

Alt activates the ribbon, A goes to the Data tab, S opens Sort & Filter, and A/D selects ascending or descending. Works in Excel 2007 and later. You can also right-click a date cell โ†’ Sort โ†’ Sort Oldest to Newest โ€” quicker when you're already in the right area.

Sorting Dates in an Excel Table

Formatted as a Table (Ctrl+T)? Click the dropdown arrow in your date column header โ€” Sort Oldest to Newest is right at the top. One click. Tables also keep row relationships intact automatically, so the expand-selection warning never appears. Add new rows and they slot into the sort order without any extra steps.

Multi-Column Sort: Date + Another Column

Go to Data โ†’ Sort (the full dialog). Click Add Level. Set the first key to your date column (Oldest to Newest), the second to another column โ€” name, priority, or anything else. Excel sorts the primary column first, then within ties it sorts by the secondary column. You can chain up to 64 levels.

Our guide on sort a column in Excel covers multi-key sorts in detail, and the principles for sort alphabetically in Excel apply directly to any text column you'd use as a tiebreaker.

Date Sorting Methods Side by Side

๐Ÿ“‹ Sort Oldest to Newest

Steps:

  1. Click any cell in your date column
  2. Go to Data tab โ†’ click Sort Oldest to Newest (Aโ†’Z with calendar icon)
  3. If prompted, choose Expand the selection to keep rows together
  4. Done โ€” dates now run from earliest to most recent

Keyboard shortcut: Alt โ†’ A โ†’ S โ†’ A

In a Table: Click the column header dropdown โ†’ Sort Oldest to Newest

Common mistake: Selecting only the date column without expanding โ€” this sorts dates but leaves all other columns in their original order, breaking the row relationships. Always expand the selection unless you have a single-column dataset.

๐Ÿ“‹ Fix Text Dates

Why it happens: Dates imported from CSV, web, or external systems often arrive as text strings. They look like dates but Excel doesn't treat them as dates.

Method 1 โ€” Text to Columns (fastest):

  1. Select the date column
  2. Data tab โ†’ Text to Columns
  3. Step 1: Choose Delimited โ†’ Next
  4. Step 2: Uncheck all delimiters โ†’ Next
  5. Step 3: Choose Date and select your format (MDY, DMY, YMD) โ†’ Finish
  6. Excel converts the text to real date values in place

Method 2 โ€” DATEVALUE formula:

=DATEVALUE(A1)

Returns the serial number for a text date. Copy the formula down, then paste as values (Ctrl+Shift+V โ†’ Values), replace the original column, and format as Date.

Common mistake: After using DATEVALUE, people forget to paste as values and delete the original column โ€” leaving formulas that reference deleted cells. Paste as values first, then delete the originals.

๐Ÿ“‹ Sort by Month or Weekday

Why you'd do this: Sometimes you want to group all January dates together regardless of year, or group all Mondays regardless of month.

Sort by month (ignoring year):

  1. Add a helper column next to your data
  2. Enter: =MONTH(A2) โ€” returns 1 (January) through 12 (December)
  3. Copy down to all rows
  4. Sort by the helper column (1โ†’12 for Jan to Dec)

Sort by day of week:

  1. Helper column: =WEEKDAY(A2) โ€” returns 1 (Sunday) through 7 (Saturday), or use =WEEKDAY(A2,2) for 1=Monday through 7=Sunday
  2. Sort helper column 1โ†’7

Excel 365 dynamic sort:

=SORT(A2:B10, 1, 1) โ€” sorts range A2:B10 by column 1, ascending. No helper column, updates automatically.

Common mistake: Forgetting to delete or hide the helper column after sorting โ€” it can confuse other users who inherit the file.

Why Your Dates Aren't Sorting Correctly

This is the most-searched question in the Excel date space โ€” and for good reason. You click Sort Oldest to Newest and the dates come out in a seemingly random order. Or the sort looks like it worked, but 2023 dates appear after 2024 dates. Or January appears before December but June appears in the middle. What's happening?

In almost every case, the answer is the same: your dates are stored as text, not as real date values. The sort by date excel not working problem has one root cause in 90% of cases, and this is it.

How to Tell If Your Dates Are Text

Real Excel dates are right-aligned in the cell by default โ€” just like numbers, because that's what they are underneath. Text values are left-aligned by default. So the quickest visual check: look at how your dates sit in the cell. Left-aligned? Almost certainly text. Right-aligned? Probably real dates.

For a definitive test, use the ISNUMBER function in a blank cell next to your date:

=ISNUMBER(A1)

If this returns TRUE, your date is a real numeric date value. If it returns FALSE, it's stored as text โ€” and it won't sort correctly. This is the most reliable diagnostic available.

A third test: try formatting the cell as a number (Home โ†’ Number Format โ†’ Number). A real date will show its serial number (something like 45292). A text date will just show the text string unchanged, because changing the format of a text cell has no effect on how Excel reads it.

You can also look for the small green triangle in the upper-left corner of a cell. That triangle is Excel's warning icon for "number stored as text" โ€” it appears when Excel suspects the cell contains something that looks numeric or date-like but is formatted as text. Click the cell, then click the yellow warning diamond that appears to the left, and choose "Convert to Number" from the dropdown.

Why Text Dates Sort Wrong

When Excel sorts text, it sorts alphabetically โ€” character by character from left to right. So "01/15/2024" sorts before "02/01/2023" because "01" comes before "02" alphabetically, even though February 2023 is actually earlier. If your dates are in MM/DD/YYYY format, the sort puts them in month order, ignoring the year entirely. If they're in DD/MM/YYYY format, they sort by day. Neither is what you want.

This is why the underlying date format in Excel matters so much โ€” not just how the date displays, but what type of value it actually is. And the way Excel handles Excel date formatting can sometimes make text dates look identical to real dates on screen, which is what makes this problem so insidious and hard to spot without running the ISNUMBER test.

Other Causes of Date Sorting Problems

A few less-common culprits worth checking when ISNUMBER returns TRUE but dates still don't sort right:

Once you've identified the issue, the fix is usually straightforward. The next section walks through both Text to Columns and DATEVALUE โ€” pick whichever suits your workflow. Most people find Text to Columns faster for a one-time fix, while DATEVALUE is better when you're building a repeatable process.

Dates Not Sorting? Checklist

Check cell alignment โ€” text dates are left-aligned, real dates are right-aligned
Run =ISNUMBER(A1) next to a date โ€” FALSE means it's stored as text
Try DATEVALUE: =DATEVALUE(A1) โ€” if it returns an error, the text format isn't recognized
Use Text to Columns (Data โ†’ Text to Columns โ†’ Finish) to bulk-convert text dates
Check for leading or trailing spaces with =LEN(A1) vs =LEN(TRIM(A1))
Verify all dates in the column use the same format (MM/DD/YYYY vs DD/MM/YYYY consistency)
Look for the green triangle warning icon โ€” indicates a number stored as text
After converting, re-apply a Date format (Home โ†’ Number Format โ†’ Short Date) and sort again

How to Fix Text Dates in Excel

You've confirmed your dates are text. Now let's fix them. There are two main approaches โ€” Text to Columns for a bulk in-place fix, and DATEVALUE for a formula-based fix that gives you more control. Both work; which you use depends on your situation.

Method 1: Text to Columns (Fastest)

This is the go-to fix when you have a whole column of text dates to convert. Select the date column, then go to Data โ†’ Text to Columns. The Convert Text to Columns Wizard opens.

In Step 1, select Delimited and click Next. In Step 2, uncheck all delimiter boxes โ€” we're not actually splitting the column, just passing through the wizard to access the date conversion option in Step 3. Click Next.

Step 3 is where the magic happens. Under Column data format, select Date from the radio buttons. Then choose your date format from the dropdown: MDY for month/day/year (US format), DMY for day/month/year (European), or YMD for ISO 8601 format. Getting this right matters โ€” choosing DMY for US-format dates will silently swap your days and months. Click Finish.

Excel converts all the selected cells from text to real date values, in place. No helper column needed. After the conversion, format the column as Date (Home โ†’ Number โ†’ Short Date or Long Date). Then sort โ€” you should see correct chronological ordering immediately.

Method 2: DATEVALUE Formula

DATEVALUE converts a text string that looks like a date into an Excel serial number. The syntax is simple:

=DATEVALUE(A1)

Put this in a blank column next to your dates and copy it down. You'll see serial numbers (like 45292) rather than formatted dates โ€” that's correct. DATEVALUE returns the underlying number. Format that column as a Date and the numbers become readable dates again.

Once you're happy with the results, copy the entire DATEVALUE column, then paste as values only โ€” Ctrl+Shift+V โ†’ Values, or right-click โ†’ Paste Special โ†’ Values. This replaces the formulas with actual serial numbers. You can then delete the original text column and keep only the converted one.

DATEVALUE works well when you want to keep the original text dates visible for reference while building a clean sorted version alongside. For the full picture of Excel date manipulation โ€” DATEVALUE alongside TODAY, NOW, DATEDIF, EDATE, and others โ€” our Excel date formulas guide covers every major date function with examples.

After converting, verify it worked: run =ISNUMBER(A1) again on a few cells โ€” they should return TRUE, and the cells should now be right-aligned. If any still show FALSE, they contained non-standard formats the wizard didn't recognize. Handle those manually or use a custom DATEVALUE with string manipulation.

Text Date Fix: Quick Formula Reference

๐Ÿ”ข
Converts text date to Excel serial number
DATEVALUE(A1)
โœ…
TRUE = real date, FALSE = text date
=ISNUMBER(A1)
๐Ÿ“‹
Ctrl+Shift+V โ†’ Values after DATEVALUE
Paste as Values
๐Ÿ“…
Home โ†’ Number โ†’ Short Date after convert
Format as Date

Sorting by Month, Weekday, or Year in Excel

Sometimes you don't want to sort by the full date โ€” you want to group by month (all Januaries together regardless of year) or by weekday (all Mondays first, then Tuesdays). Standard date sorting won't do this. You need a helper column approach.

Sort by month only: Add a column with =MONTH(A2). This extracts the month as a number โ€” 1 through 12. Sort that helper column from smallest to largest and your data groups by calendar month, with all Januaries together, all Februaries together, and so on. If you want year as a tiebreaker within the same month, open the full Sort dialog and add a second level using a =YEAR(A2) helper.

Sort by day of week: Use =WEEKDAY(A2), which returns 1 (Sunday) through 7 (Saturday) by default. If you want Monday as 1, use =WEEKDAY(A2, 2). Sort the helper column 1โ†’7 to group all Sundays (or Mondays) at the top, then Tuesdays, through to the end of the week.

After sorting, hide the helper column (right-click โ†’ Hide) rather than deleting it โ€” that way you can re-sort by it later without rebuilding the formula. You might also want to how to change column width in excel to keep your worksheet tidy with helper columns included.

Dynamic sort with SORT function (Excel 365 only):

=SORT(A2:B10, 1, 1)

This formula sorts the range A2:B10 by the first column, ascending (use -1 for descending). It spills the sorted results into adjacent blank cells and updates automatically whenever source data changes โ€” no manual re-sorting ever again. To sort by the second column instead: =SORT(A2:C10, 2, -1).

The SORT function is only available in Excel 365 and Excel 2021. Excel 2016 and 2019 don't have it โ€” use the helper column method instead.

Need to separate names before sorting by a text column? Our guide on separate first and last name in excel walks through that โ€” useful when you're building multi-level sorts with both date and name columns. And if you're working with date-based count conditions, the countifs excel guide shows how to combine COUNTIFS with date criteria for targeted analysis.

Date Sort Troubleshooting Workflow

โ–ถ๏ธ

Select a cell in the date column. Data tab โ†’ Sort Oldest to Newest. Check whether the result looks chronological.

๐Ÿ”

Look at alignment (right = real date, left = text). Run =ISNUMBER(A1) โ€” TRUE means real, FALSE means text. If FALSE, proceed to step 3.

๐Ÿ”„

Select the date column. Data โ†’ Text to Columns โ†’ Delimited โ†’ Next โ†’ uncheck all delimiters โ†’ Next โ†’ select Date format (MDY/DMY/YMD) โ†’ Finish.

๐Ÿ“…

After conversion, sort again with Data โ†’ Sort Oldest to Newest. Check for expand selection prompt and confirm.

โœ…

Scan first and last few rows. Confirm the earliest date is at the top (or bottom for newest-first). Run =ISNUMBER on a few cells to confirm real dates. Done.

Excel Date Sorting: Quick Reference Numbers

1๏ธโƒฃ
Serial number 1 โ€” Excel's date origin
Jan 1, 1900
๐Ÿ“Š
Converts text date string to serial number
DATEVALUE
๐Ÿ“…
Returns 1โ€“12 from a date โ€” use for month-only sort
MONTH()
๐Ÿ“†
Returns 1โ€“7 from a date โ€” use for day-of-week sort
WEEKDAY()
๐Ÿ”„
Excel 365+ only โ€” dynamic auto-sorting array formula
SORT function

Text to Columns vs DATEVALUE: Which Fix to Use?

Pros

  • Text to Columns: In-place conversion โ€” no helper column, no paste-as-values step
  • Text to Columns: Works on entire column at once โ€” fast for large datasets
  • Text to Columns: Handles mixed formats with explicit MDY/DMY/YMD selection
  • DATEVALUE: Non-destructive โ€” original text dates stay untouched
  • DATEVALUE: Works inside formulas โ€” can combine with other functions
  • DATEVALUE: Useful when building automated pipelines that refresh data

Cons

  • Text to Columns: Overwrites the original column โ€” no undo beyond Ctrl+Z
  • Text to Columns: Won't work on dates already formatted as Date (only for text-stored values)
  • Text to Columns: Requires correct format selection โ€” wrong MDY/DMY setting corrupts dates silently
  • DATEVALUE: Returns an error if the text format isn't recognized โ€” requires consistent input
  • DATEVALUE: Requires extra paste-as-values step before you can delete the original column
  • DATEVALUE: Doesn't auto-convert โ€” must be copied down manually for each row
Take Free Excel Formulas Practice Test

Excel Questions and Answers

How do I sort dates in Excel oldest to newest?

Click any cell in your date column, then go to the Data tab and click Sort Oldest to Newest (the Aโ†’Z button with a calendar icon). If Excel prompts you to expand the selection, choose Expand โ€” this keeps all rows together. Your dates will sort from earliest to most recent. If the sort doesn't work correctly, your dates may be stored as text โ€” check by looking at their alignment (left-aligned = text). Use Data โ†’ Text to Columns to convert them first.

Why are my dates not sorting correctly in Excel?

The most common reason is that your dates are stored as text rather than real date values. Text dates are left-aligned in the cell, while real dates are right-aligned (like numbers). You can confirm with =ISNUMBER(A1) โ€” if it returns FALSE, the date is text. Fix it with Data โ†’ Text to Columns โ†’ select Date format โ†’ Finish. Other causes include mixed date formats in the same column, leading/trailing spaces, or dates from different regional settings.

How do I fix text dates in Excel so they sort correctly?

The fastest fix is Text to Columns: select the date column, go to Data โ†’ Text to Columns, click through to Step 3, select Date as the column format with the correct order (MDY for US dates, DMY for European), then click Finish. Excel converts the text to real date values in place. Alternatively, use =DATEVALUE(A1) in a helper column to get the serial number, then paste as values and format as Date.

What is the keyboard shortcut to sort dates in Excel?

Press Alt โ†’ A โ†’ S โ†’ A (in sequence, not simultaneously) to sort oldest to newest. Press Alt โ†’ A โ†’ S โ†’ D to sort newest to oldest. These are ribbon keyboard shortcuts: Alt activates the ribbon, A goes to the Data tab, S opens Sort & Filter, and A/D selects ascending or descending. They work in Excel 2007 and later on Windows.

How do I sort by month in Excel (ignoring the year)?

Add a helper column with =MONTH(A2) and copy it down. This extracts the month number (1 through 12) from each date. Then sort by the helper column from smallest to largest โ€” all January dates group together, then February, and so on, regardless of year. If you want year as a tiebreaker, use a custom sort (Data โ†’ Sort) and add Year as a second level using =YEAR(A2) in another helper column.

How do I sort by year in Excel?

If your dates are real Excel dates, a standard oldest-to-newest sort automatically sorts by year (and month and day within the year). If you specifically want to sort by year only โ€” grouping all dates from the same year together regardless of month โ€” add a helper column with =YEAR(A2) and sort by that column. All 2022 dates group together, then 2023, etc.

How do I sort multiple columns where one is a date?

Go to Data โ†’ Sort (the full dialog, not the quick buttons). In the Sort dialog, your first sort key is the date column โ€” set it to Oldest to Newest or Newest to Oldest. Click Add Level to add a second column as a tiebreaker (e.g., sort alphabetically by name for rows with the same date). You can add up to 64 sort levels. Click OK to apply the multi-level sort.

How do I use the SORT function to sort dates in Excel 365?

The SORT function dynamically sorts a range and spills results to adjacent cells. To sort dates in column A with related data in column B: =SORT(A2:B10, 1, 1) sorts by column 1 (the date), ascending. For newest first: =SORT(A2:B10, 1, -1). The results update automatically when source data changes. SORT is only available in Excel 365 and Excel 2021 โ€” not in 2016 or 2019.
Take Free Excel MCQ Practice Test
โ–ถ Start Quiz