Why date columns sort incorrectly in a CSV file
Learn why CSV dates sort out of order, how to spot text and mixed formats, and how to standardize values before sorting rows safely.
You sort a CSV by its date column, but the rows end up in a strange order. Dates from April may appear before dates from February, or values such as 3/4/2025 may be treated differently on another computer.
A CSV file stores values as text, not as dates with a built-in date format. The app that opens it has to guess what each value means. Use the CSV Editor to inspect the column and check its order, then standardize the dates before sorting.
Check the date column
- Open a copy of the file in the CSV Editor. Keep the original unchanged until you have checked the result.
- Find the date column and scan values from the top, middle, and bottom. Look for different patterns, such as
2025-04-03,4/3/2025, and03-Apr-2025. - Check whether some rows include a time, such as
2025-04-03 14:30, while others contain only a date. Also look for blank cells, extra spaces, or dates with two-digit years. - Use the column's sort option to inspect the order. Check whether the rows stay together as complete records, and do not export or overwrite the original until the results make sense.
If you are unsure what a format means, compare it with the system or application that created the file. For example, 03/04/2025 could mean March 4 or April 3, depending on the convention used.
What the sort order means
Dates sort by their first characters
If values appear in an order like 1/10/2025, 11/2/2024, then 2/1/2025, the app may be sorting them as text. A text sort compares characters from left to right. It does not know that the values represent calendar dates, so the month or day at the start can outweigh the year.
Some dates appear in the wrong century or year
A value such as 4/3/25 may be interpreted differently from 4/3/2025. Apps can also apply different rules to two-digit years. Use four-digit years throughout, and confirm the intended century before changing values.
Only some rows are out of order
The column may contain mixed formats, spaces, or values that are not dates, such as unknown or N/A. A spreadsheet may recognize some cells as dates and leave others as text. Check the unusual rows and decide whether to correct, remove, or keep non-date values separately.
Dates with times seem to move across days
A timestamp includes a time of day, and sometimes a time zone. Two entries that show the same calendar date in different time zones can represent different moments. If you need to sort by exact time, make the time zone consistent before sorting.
How to fix the sort
- Confirm the date convention. Find out whether the source uses month/day/year or day/month/year. Do not convert ambiguous values by guessing. Check the source system, a report, or a date you can verify independently.
- Standardize the values. Use one format throughout the column. For dates without times,
YYYY-MM-DD, such as2025-04-03, is a reliable choice. Year first, followed by a two-digit month and day, puts the values in calendar order even when an app sorts the characters as text. - Import with the right locale when using a spreadsheet. In Excel on Windows 11 or macOS, choose Data › From Text/CSV and check the date column's detected type and regional interpretation before loading it. If the preview reads dates incorrectly, change the locale or import the column as text and convert it using the confirmed source pattern. Options can vary by Excel version.
- Sort complete rows by the date column. Select the whole data range or use the spreadsheet's table sort, with the date column as the key. Sorting just the date cells can detach dates from the names, amounts, or other fields in the same rows.
- Check the exported CSV again. Save the edited data as CSV, reopen the saved file, and inspect several rows. CSV does not preserve spreadsheet formatting or date types, so verify that the actual saved values use the format you intended.
For another common cause, see Mixed date formats in a CSV: what to check. It covers how to identify inconsistent date patterns before importing or sorting.
Why CSV files do this
CSV stands for comma-separated values. It is a plain-text format that separates fields with commas or, in some regional settings, another delimiter. It does not include a rule saying that a particular column contains dates, numbers, or text. The spreadsheet or editor makes that decision when it opens the file.
That guess can depend on your computer's regional settings. In the United States, 4/3/2025 commonly means April 3. In places that use day/month/year, it commonly means March 4. A value such as 2025-04-03 is less ambiguous and sorts naturally by year, month, and day as text.
For timestamps, decide whether the column represents a local clock time or a specific moment. If it represents moments across locations, convert them to one time zone, often UTC, before sorting. Keep the original time zone in a separate column if you need to show how the source recorded each entry.
The CSV Editor opens and processes your file in the browser, so the file stays on your device.
