Google Sheets Sort by Date Automatically: How-To
In this article
Google Sheets can sort by date automatically, but not with a single built-in switch. The reliable way is to use a formula-driven sorted view or a small Apps Script trigger that re-sorts the sheet when data changes. For most people, a helper sheet with the SORT function is the safest, fastest option because it updates the moment a new date is entered and never touches your original data. If you need the actual rows reordered in place, an installable edit trigger is the alternative. This guide walks through both, plus the date-format traps that make sorting fail.
What You'll Need
- A Google account with access to Google Sheets (desktop browser recommended for setup).
- A sheet with a real date column. Dates must be true date values, not text that looks like a date.
- For the in-place method: permission to add an Apps Script trigger to the file. If the sheet is shared, you need edit access.
- Optional: a second tab for the sorted view so your source data stays untouched.
Step-by-Step
Method 1: Automatic sorted view with the SORT function (recommended)
- Open your sheet and confirm the date column contains real dates. Click a date cell and check that the formula bar shows a date value, not a left-aligned text string. Left-aligned dates are text and will sort alphabetically, not chronologically.
- If dates are text, convert them: select the column, then use Format > Number > Date. If that does nothing, the values are text. Use Data > Split text to columns or re-enter them in a recognised format such as YYYY-MM-DD.
- Add a new tab at the bottom and name it something like Sorted. This keeps your raw data intact.
- In cell A1 of the new tab, enter a SORT formula that references your source range. For example, if your data is on a tab called Data in columns A to D with dates in column B, use
=SORT(Data!A2:D, 2, TRUE). The2is the column index of the date column within the range, andTRUEsorts oldest to newest. UseFALSEfor newest first. - Press Enter. The sorted view populates automatically. Add a new row to the source tab and the sorted tab updates within a moment, no manual action needed.
- If you want the header row preserved, either include it in the range and let SORT keep it at the top, or reference only the data rows as shown above and type your headers manually in row 1 of the sorted tab.
Method 2: Re-sort the actual rows automatically with Apps Script
- Open the sheet in a desktop browser. In the menu, go to Extensions > Apps Script. Labels can differ slightly by version and region.
- Delete the placeholder code and paste a short onEdit function that sorts the sheet by your date column. The script should read the edited range, check that the edit is in the date column, then call the sheet's sort method with the date column and ascending order.
- Save the project and give it a name.
- In the Apps Script editor, open the Triggers area (clock icon in the left sidebar) and add a trigger: choose your function, choose From spreadsheet as the event source, and On edit as the event type.
- Authorise the script when prompted. Google will ask you to review permissions for the account. This is expected for a script that edits your own file.
- Test it: change a date in the source sheet and watch the rows reorder. If nothing happens, check the trigger is saved and the function name matches.
Note: an onEdit trigger runs on edits made by a user, not on values arriving through a formula or an import. If your dates come from a connected form or another sheet, use a time-driven trigger instead, or stick with Method 1.
Common Mistakes
- Dates stored as text. This is the number one cause of wrong order. Text dates sort by character, so 01/02/2024 can land after 12/01/2023. Always check alignment and the formula bar.
- Mixed date formats in one column. US and international formats in the same column confuse Sheets. Standardise on one format before sorting.
- Sorting only part of the range. If you select just the date column and sort, the other columns stay put and rows break apart. Select the whole table or use SORT.
- Forgetting the header. Sorting a range that includes a header without telling Sheets it is a header moves the header into the data.
- Expecting a filter view to reorder rows. Filter views hide rows; they do not permanently reorder them. Use SORT for a live ordered view.
- Editing the sorted tab directly. A SORT formula output cannot be edited in place. Change the source tab instead.
Tips
- Use ISO format (YYYY-MM-DD) in the source column. It sorts correctly as text too, which makes it a useful fallback.
- Add a second sort key for ties, for example
=SORT(Data!A2:D, 2, TRUE, 1, TRUE)to sort by date then by name. - Wrap the SORT in
IFERRORif the source range may be empty, so the tab shows a blank instead of an error. - Keep the source tab as the single entry point. Everything downstream, including charts and pivot tables, can point at the sorted tab.
- If you use Apps Script, add a comment at the top of the script explaining what it does, so a future editor does not delete it by accident.
- Freeze the header row on the sorted tab so it stays visible while scrolling.
Troubleshooting
The sorted tab shows an error. Check that the sheet name in the formula matches exactly, including spaces. Sheet names with spaces need single quotes, for example ='My Data'!A2:D.
Dates sort in the wrong order. Confirm the column index in SORT points at the date column, not a neighbouring one. Then re-check that the date cells are real dates.
The Apps Script trigger does nothing. Open the trigger list and confirm it is saved and enabled. Check the execution log for errors. If the sheet is shared, remember the trigger runs under the account that created it.
New rows do not appear in the sorted tab. The SORT range is fixed. Extend it, or use an open-ended range such as Data!A2:D without a row limit, which already covers new rows below.
Sorting breaks other formulas. Formulas that reference specific cells will follow the move. If that is a problem, use the sorted-view method so the source rows never move.
Frequently Asked Questions
Can Google Sheets sort by date automatically without a script?
Yes, using the SORT function on a separate tab. It recalculates whenever the source data changes, so the view stays ordered without any manual sorting.
Why does my date column sort alphabetically?
The cells are text, not dates. Convert them with Format > Number > Date, or re-enter them in a recognised format.
Does sorting a range move my formulas?
Yes. Sorting rows in place moves cell contents, including formulas, and relative references adjust. A sorted view avoids this because the source stays untouched.
Can I sort newest first?
Yes. In SORT, set the ascending argument to FALSE. In the manual sort dialog, choose Z to A for the date column.
Will an onEdit trigger fire when a Google Form adds a row?
No. Form submissions and formula results do not count as user edits. Use a time-driven trigger or the SORT function instead.
Can I sort by date on the mobile app?
You can sort a selected range manually from the Sheets mobile app, but creating the SORT formula and setting up script triggers is far easier on a desktop browser.