# How to filter rows from the last 30 days in Excel

Keep the rows dated from today minus 30 to today: `=FILTER(A2:C9,(A2:A9>=F1-F2)*(A2:A9<=F1),"No rows")`.

**Excel:** `=FILTER(A2:C9,(A2:A9>=F1-F2)*(A2:A9<=F1),"No rows")` (Excel 2021, 2024 and Microsoft 365)

**Google Sheets:** `=FILTER(A2:C9,A2:A9>=F1-F2,A2:A9<=F1)`

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Date | Customer | Amount |  | Today | 2026-10-29 |
| 2026-09-15 | Acme | 420 |  | Days back | 30 |
| 2026-09-29 | Brightline | 1280 |  | Last 30 days |  |
| 2026-10-03 | Cobalt | 760 |  |  |  |
| 2026-10-14 | Acme | 315 |  |  |  |
| 2026-10-22 | Dunmore | 990 |  |  |  |
| 2026-10-29 | Brightline | 540 |  |  |  |
| 2026-10-30 | Cobalt | 210 |  |  |  |
| 2026-08-28 | Dunmore | 1150 |  |  |  |

Formula in E4: `=FILTER(A2:C9,(A2:A9>=F1-F2)*(A2:A9<=F1),"No rows")`

Result (spills 5 × 3): 9/29/2026, Brightline, $1,280; 10/3/2026, Cobalt, $760; 10/14/2026, Acme, $315; 10/22/2026, Dunmore, $990; 10/29/2026, Brightline, $540

## How it works

`F1-F2` is the date 30 days before today. Multiplying the two tests keeps the rows on or after that date and on or before today, and FILTER returns the whole matching rows. The October 30 row is in the future, so it is left out. Change F2 to 7 or 90 for other windows.

## Other ways

- `=FILTER(A2:C9,A2:A9>=F1-F2,"No rows")`: Without the upper limit, future-dated rows are included. (Includes the October 30 row.)

## Common mistakes

- "Last 30 days" can mean 30 or 31 calendar days depending on whether today counts. Here today and the 30 days before it are included; use `>F1-F2` for exactly 30.
- Google Sheets FILTER takes each condition as its own argument and has no "if empty" value; wrap it in IFERROR for that.

## Questions

**How do I total the last 30 days instead?**

`=SUMIFS(C2:C9,A2:A9,">="&F1-F2,A2:A9,"<="&F1)`.

**How do I filter the last full calendar month?**

Use the month bounds: `(A2:A9>=EOMONTH(F1,-2)+1)*(A2:A9<=EOMONTH(F1,-1))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/filter-rows-from-the-last-30-days
