logo
search
Calculation Issues

How to Filter Excel Data for the Last 30 Days Relative to Today

Chanuka GeekiyanageChanuka Geekiyanage Oct 10, 2026 868 views

Question details

The user needs to filter a SharePoint-hosted Excel workbook to show records strictly from the last 30 days.

How to Filter Excel Data for the Last 30 Days Relative to Today
Product
Excel
Device & OS
not provided
Scenario
Creating a dynamic filter for a rolling 30-day date range rather than filtering by a static calendar month.
Observed behavior
The user wants an automated or formula-based way to identify and filter rows that fall within the 30-day window relative to the current date.
Before you start

Ensure your date column contains valid, system-recognized dates rather than plain text, and note that VBA macros are not supported if you are running Excel for the Web in a browser.

Solution 1Recommended

Use a Helper Column with the TODAY() Function

Create an extra column with a logical formula that checks if each date falls within the last 30 days, then apply a standard filter.

This is the most reliable method for dynamically filtering rolling dates without needing complex macros or scripts. By utilizing the TODAY() function, the filter automatically shifts forward every day.

1
Create a Helper Column

Insert a new column next to your data and name the header something descriptive, like 'Last 30 Days'.

2
Enter the Formula

In the first data cell of the new column (e.g., B2), type the formula: =AND(A2>=TODAY()-30,A2<=TODAY()). Make sure to replace 'A2' with the cell reference containing your actual date.

3
Apply to All Rows

Press Enter, then drag the fill handle (the small square at the bottom-right of the cell) down to copy this formula to the rest of your dataset.

4
Filter for TRUE

Select your column headers, navigate to the 'Data' tab, and click 'Filter'. Click the filter dropdown on your helper column and check only the box for 'TRUE'.

Use a Helper Column with the TODAY() Function
Make the Timeframe Configurable: Instead of hardcoding '30', type the number of days in an empty cell like C1. Then change your formula to =AND(A2>=TODAY()-$C$1,A2<=TODAY()). This allows you to easily switch between 7, 30, or 90 days without rewriting the formula.
Manage Data Effectively

Easily Filter Data by Dynamic Dates with WPS Spreadsheet

WPS Office provides a highly compatible and lightweight spreadsheet tool that flawlessly executes dynamic formulas like TODAY() and AND(), making it effortless to track rolling date ranges.

  1. 1. Open Your Workbook: Launch WPS Spreadsheet and open the file containing your date records.
  2. 2. Set Up the Formula: Add a new column next to your dates and enter the formula =AND(A2>=TODAY()-30,A2<=TODAY()).
  3. 3. Filter the Results: Go to the 'Data' tab, click 'AutoFilter', and filter your new column to display only the 'TRUE' values.
Fully compatible with Microsoft Excel formats (.xlsx and .xls)Supports advanced date and logical formulas for dynamic filteringLightweight, fast, and completely free to download
QA img-9

Frequently Asked Questions

Can I filter for the last 7 or 90 days instead of 30?

Yes, simply modify the number in your formula. For example, use =AND(A2>=TODAY()-7,A2<=TODAY()) to filter data from the last 7 days. You can also point the formula to a specific cell that holds your desired number of days.

Why won't my VBA macro work for filtering in SharePoint?

SharePoint opens files using Excel for the Web (the browser version), which does not support executing VBA macros. To automate tasks in the web version, you must use Office Scripts.

How do I filter dates specifically for the previous calendar month?

If you want the strict calendar month (e.g., all of October) rather than a rolling 30-day window, you do not need a formula. Simply click the filter dropdown arrow on your date column header, navigate to 'Date Filters', and select 'Last Month'.