Filter Data by Date Range in Google Sheets

This tutorial elaborates on how to filter data by date range using the Filter menu, QUERY function, or FILTER function in Google Sheets.

If you use the Filter menu filtering feature, you can filter the source data, whereas the formulas (QUERY and FILTER) will return the filtered data in a new range. Choose the one based on your preference.

Filtering Data by Date Range Using the Filter Menu

    We have data in columns A and B, and column A contains dates. Let’s apply a filter to the date column first.

    1. Select column A.
    2. Click Data > Create a filter.

    In the top row, in two blank cells, enter the start and end dates to filter the date column. For example, enter the start date in cell C1 and the end date in cell D1.

    Now, let’s proceed to the steps to filter this data by the given date range.

    Steps:

    1. Click on the filter drop-down in cell A1 and click “Filter by condition”.
    2. From the drop-down below, select “Is between”.
    3. Enter =$C$1 in the first field and =$D$1 in the second field. The cell references must be static, which is why the $ sign is included with the criteria references.
    4. Click “OK”.
    Creating a Filter Using 'Is Between'

    When you want to filter by a different date range, enter those dates in C1 and D1. Then, simply click the filter drop-down in cell A1 and click “OK”.

    These two actions are required each time you change the filter criterion in cells C1 and D1, which makes this approach non-dynamic.

    Note: If you want to filter out the dates that fall within the given date range, in step 2 above, select “Is not between” instead of “Is between”.

    Filtering Data by Date Range Using Formulas

    If you prefer using formulas, I suggest you enter them in a new sheet within the source data file.

    You won’t be able to edit the formula results directly. Any changes you want to make should be made to the source data, and they will be immediately reflected in the formula output.

    We can use either the FILTER or QUERY functions to filter data by date range in Google Sheets.

    Out of these two, the FILTER function is easier to apply. So let’s start with that.

    FILTER Function Approach

    Assume our sample data is in A1:B in Sheet1 where A1:B1 contains the field labels. In another empty sheet in that file, enter the date range in A1:B1.

    Then enter this formula in cell A3:

    =FILTER(Sheet1!A2:B, ISBETWEEN(Sheet1!A2:A, A1, B1))
    Filtering Data by Date Range Using the FILTER Function in Google Sheets

    This follows the syntax FILTER(range, condition1, [condition2, …]).

    Where:

    • range: Sheet1!A2:B (the source data range excluding the header row).
    • condition: ISBETWEEN(Sheet1!A2:A, A1, B1) (it returns TRUE wherever the dates in Sheet1!A2:A fall within the range A1 and B1).

    The FILTER function filters the rows wherever the condition is TRUE.

    Note: If you want to filter out the dates that fall within the given date range, simply wrap the ISBETWEEN function with NOT, which turns FALSE to TRUE and TRUE to FALSE.

    =FILTER(Sheet1!A2:B, NOT(ISBETWEEN(Sheet1!A2:A, A1, B1)))

    Now, we will see how to filter date ranges using the QUERY function in Google Sheets.

    QUERY Function Approach

    One advantage of QUERY is that it can include the header row in the formula. It recognizes the header row and ensures it is not filtered out.

    However, unlike FILTER, it may be a little more challenging to remember the correct use of date criteria in QUERY.

    =QUERY(Sheet1!A1:B, "SELECT A, B WHERE A>=DATE '"&TEXT(A1,"yyyy-mm-dd")&"'  AND  A<=DATE '"&TEXT(B1,"yyyy-mm-dd")&"' ", 1) 
    Filtering Data by Date Range Using the QUERY Function in Google Sheets

    This QUERY formula filters the data in A1:B in Sheet1 by the given date range in cells A1 and B1 in the formula-entered sheet.

    It follows the syntax QUERY(data, query, [headers]).

    Where:

    • data: Sheet1!A1:B
    • query: "SELECT A, B WHERE A>=DATE '"&TEXT(A1,"yyyy-mm-dd")&"' AND A<=DATE '"&TEXT(B1,"yyyy-mm-dd")&"' ": filters the dates in column A between the specified dates in cells A1 and B1.
    • headers: 1 (the number of header rows in the data)

    Note: To filter the data for the date range that does not fall within the dates specified in cells A1 and B1, use the following QUERY:

    =QUERY(Sheet1!A1:B, "SELECT A, B WHERE A<DATE '"&TEXT(A1,"yyyy-mm-dd")&"'  OR  A>DATE '"&TEXT(B1,"yyyy-mm-dd")&"' ", 1) 

    Resources

    Prashanth KV
    Prashanth KV
    Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

    Highlight Upcoming Birthdays in Google Sheets

    When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

    Compare Two Tables for Differences in Excel

    To compare two tables with similar data for differences, you can use the XLOOKUP...

    Calculate Weighted Average in Pivot Table in Google Sheets

    You can calculate a weighted average in a Pivot Table using a custom formula...

    Summarize Data and Keep the Last Record in Google Sheets

    In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

    More like this

    Highlight Upcoming Birthdays in Google Sheets

    When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

    Calculate Weighted Average in Pivot Table in Google Sheets

    You can calculate a weighted average in a Pivot Table using a custom formula...

    Summarize Data and Keep the Last Record in Google Sheets

    In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

    2 COMMENTS

      • Hi, Seema,

        It works for me!

        Please note one thing.

        When you update the criteria, i.e., dates in H1 and J1, those won’t reflect in the filter.

        You should click the filter down-arrow in F1 (filter column) and click OK to reflect those changes.

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here

    This site uses Akismet to reduce spam. Learn how your comment data is processed.