# How to filter between two dates with QUERY in Google Sheets

Build the dates into the query as yyyy-mm-dd text: `=QUERY(A1:F13,"select A, B, F where A >= date '"&TEXT(I1,"yyyy-mm-dd")&"' and A <= date '"&TEXT(I2,"yyyy-mm-dd")&"'",1)`.

**Google Sheets:** `=QUERY(A1:F13,"select A, B, F where A >= date '"&TEXT(I1,"yyyy-mm-dd")&"' and A <= date '"&TEXT(I2,"yyyy-mm-dd")&"'",1)`

**Excel:** Excel has no QUERY function. Use FILTER with two date tests: `=FILTER(A2:F13,(A2:A13>=I1)*(A2:A13<=I2))`.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F | G | H | I |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Date | Rep | Region | Product | Units | Revenue |  | From | 2026-07-14 |
| 2026-07-03 | Ana Ruiz | East | Widget | 40 | 2080 |  | To | 2026-08-04 |
| 2026-07-06 | Raj Patel | West | Gadget | 25 | 2225 |  |  |  |
| 2026-07-10 | Lee Chen | East | Gizmo | 12 | 1740 |  |  |  |
| 2026-07-14 | Ana Ruiz | North | Gadget | 30 | 2670 |  |  |  |
| 2026-07-17 | Kim Ortiz | West | Widget | 55 | 2860 |  |  |  |
| 2026-07-21 | Raj Patel | East | Widget Pro | 18 | 1422 |  |  |  |
| 2026-07-24 | Lee Chen | South | Gadget | 22 | 1958 |  |  |  |
| 2026-07-29 | Kim Ortiz | East | Gizmo | 9 | 1305 |  |  |  |
| 2026-08-04 | Mo Diaz | North | Gizmo | 14 | 2030 |  |  |  |
| 2026-08-07 | Raj Patel | South | Widget | 20 | 1040 |  |  |  |
| 2026-08-12 | Kim Ortiz | North | Gadget | 16 | 1424 |  |  |  |
| 2026-08-18 | Mo Diaz | East | Gizmo Mini | 28 | 1092 |  |  |  |

Formula in H4: `=QUERY(A1:F13,"select A, B, F where A >= date '"&TEXT(I1,"yyyy-mm-dd")&"' and A <= date '"&TEXT(I2,"yyyy-mm-dd")&"'",1)`

Result (spills 7 × 3): Date, Rep, Revenue; 7/14/2026, Ana Ruiz, $2,670; 7/17/2026, Kim Ortiz, $2,860; 7/21/2026, Raj Patel, $1,422; 7/24/2026, Lee Chen, $1,958; 7/29/2026, Kim Ortiz, $1,305; 8/4/2026, Mo Diaz, $2,030

## How it works

QUERY only recognizes a date written as the word `date` followed by the date in single quotes, in yyyy-mm-dd form. `TEXT(I1,"yyyy-mm-dd")` turns the date in the cell into exactly that text, so the query reads `where A >= date '2026-07-14' and A <= date '2026-08-04'`. The `and` makes a range.

## Other ways

- `=QUERY(A1:F13,"select A, B, F where A >= date '2026-07-14' and A <= date '2026-08-04'",1)`: Typed dates work too, for a one-off report.
- `=FILTER({A2:A13,B2:B13,F2:F13},A2:A13>=I1,A2:A13<=I2)`: FILTER compares real dates with no text conversion. No header row. (No header row.)

## Common mistakes

- `where A >= I1` or `where A >= '7/14/2026'` doesn't work: QUERY needs the date keyword and the yyyy-mm-dd form.
- If the column holds dates with times, use `datetime '2026-08-04 23:59:59'`, or compare with < the next day.
- Dates stored as text in the source column are ignored, because QUERY gives each column one type.

## Questions

**How do I get the last 30 days?**

Use TODAY in the TEXT: `"where A >= date '"&TEXT(TODAY()-30,"yyyy-mm-dd")&"'"`.

**How do I filter one month?**

Use month(), which counts from 0: `where month(A) = 6` is July. Add `and year(A) = 2026` for a single year.

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-between-two-dates-with-query
