COUNTIFS between two dates
COUNTIFS counts rows that meet every condition you give it, such as tickets created within one month that have a status of Closed.
=COUNTIFS($A$2:$A$3000,">="&F1,$A$2:$A$3000,"<="&EOMONTH(F1,0),$B$2:$B$3000,"Closed")The sheet: Tickets sheet: column A is Created date, column B is Status (Open, Pending, or Closed). F1 holds the first day of the month you want to count.
How it works, step by step
- 01F1 holds the first day of the month, for example 1-Mar-2026.
- 02EOMONTH(F1,0) returns the last day of that same month, 31-Mar-2026.
- 03">="&F1 and "<="&EOMONTH(F1,0) build the two date tests on the Created date column, $A$2:$A$3000.
- 04$B$2:$B$3000,"Closed" adds a third test on Status.
- 05COUNTIFS counts rows that pass all three tests. For March that might be 214 closed tickets.
The same logic in four tools
=COUNTIFS($A$2:$A$3000,">="&F1,$A$2:$A$3000,"<="&EOMONTH(F1,0),$B$2:$B$3000,"Closed")=COUNTIFS($A$2:$A$3000,">="&F1,$A$2:$A$3000,"<="&EOMONTH(F1,0),$B$2:$B$3000,"Closed")SELECT COUNT(*) AS closed_tickets
FROM tickets
WHERE created_date >= DATE '2026-03-01'
AND created_date < DATE '2026-04-01'
AND status = 'Closed';import pandas as pd
mask = (
(tickets["created_date"] >= "2026-03-01")
& (tickets["created_date"] < "2026-04-01")
& (tickets["status"] == "Closed")
)
closed_tickets = int(mask.sum())Mistakes that break it
- !If Created date holds a timestamp like 31-Mar-2026 14:20, "<="&EOMONTH(F1,0) excludes it, because EOMONTH returns midnight. Use "<"&EOMONTH(F1,0)+1 for timestamp data.
- !COUNTIFS text criteria ignore case, so closed and Closed both count. In Postgres, = is case-sensitive, so use LOWER(status) = 'closed' if the data is inconsistent.
- !Dates imported from a CSV as text are not counted. =ISNUMBER(A2) returns TRUE for a real date and FALSE for text that only looks like one.
- !Typing a date straight into the criteria, like ">=3/1/2026", depends on the file's locale date order. A cell reference or DATE(2026,3,1) avoids that.
Common questions
- How do I count dates between two dates in Excel?
- Use COUNTIFS with the date column twice: =COUNTIFS(A2:A3000,">="&F1,A2:A3000,"<="&F2). Each pair is one condition, and a row is counted only when both are true.
- How do I count rows for a specific month?
- Put the first day of the month in a cell, use it as the start date, and use EOMONTH(cell,0) as the end date. This avoids hard-coding the number of days in each month.
- What is the pandas equivalent of COUNTIFS?
- Build a boolean mask with one comparison per condition, joined with &, then call .sum() on the mask. Each True counts as 1.
Got a version of this with your own ranges?
Paste it into the free translator and get the same breakdown for your exact formula. To run it against a real file, upload the CSV and describe the formula you need in a sentence.