Excel dates are serial numbers, so you can manipulate them with simple math operations. The TODAY function always returns the current date. Inside the AND function, the first logical test checks to see if the date in B5 is greater than or equal to today’s date minus 7 days: The second logical test checks if the date is less than today: when both results are TRUE, the AND function will return TRUE. If either result is FALSE, the AND function will return FALSE.
Without future checks
The second test is meant to exclude any dates greater than (or equal to) today. This test only makes sense if data may include dates in the future, for example forecasts or estimates. If there are no future dates, or if you want future dates included, the formula can be simplified to:
Return custom value
This formula can be combined with the IF function to return any value you want. For example, to return “Last 7” when a date is within last 7 days, and nothing if not, you can use:
Dave Bruns
Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.