Answers / Question 26

SUMIFS / COUNTIFS between two dates leaves out the last day (or returns 0): Excel + Google Sheets fix

Why a SUMIFS or COUNTIFS date range drops everything from the end date when your dates carry times, the one-line fix, tested month and week totals with EOMONTH and EDATE, and the criteria mistakes that make the total 0.

The problem

You total sales, hours or orders between a start date and an end date with SUMIFS (or count them with COUNTIFS), and the result is too low. When you check by hand, everything from the last day of the range is missing: the October report leaves out October 31, the weekly one leaves out Friday. Or the formula returns 0 even though the rows are right there.

Inspired by a public question on Stack Overflow. The problem above is described in our own words and the solution below is ours.

Why it happens

Both apps store a date as a whole number and a time as the fraction after it: Oct 31, 2026 6:45 PM is the 31st plus 0.78 of a day. A date typed into a cell, like your end date 10/31/2026, means midnight at the start of that day. So the condition "<="&F2 only lets in rows up to 12:00 AM on the 31st, and every entry later that day falls outside it.

The sheet often hides this: a column formatted to show only the date can still hold times. Data from forms (Google Forms timestamps), point-of-sale and booking exports, NOW() and Apps Script new Date() nearly always includes them.

How many dates in A2:A500 have a time part (0 = none, so this isn't your problem)Formula
=SUMPRODUCT((A2:A500<>"")*(MOD(A2:A500,1)>0))

If that formula shows #VALUE!, some "dates" are actually text; see the last section.

The fix: "before the day after" instead of "on or before"

With dates in A, amounts in C, the start date in F1 and the end date in F2, change <= to < and add 1 to the end date. That reads "before midnight at the start of the next day", which covers the whole last day whatever the times are. It gives the same result on plain dates too, so you can use it everywhere.

Total from F1 through F2, the whole last day includedFormula
=SUMIFS(C2:C500,A2:A500,">="&F1,A2:A500,"<"&F2+1)
Count the rows in the same rangeFormula
=COUNTIFS(A2:A500,">="&F1,A2:A500,"<"&F2+1)
Add more conditions as extra pairs, e.g. region EastFormula
=SUMIFS(C2:C500,A2:A500,">="&F1,A2:A500,"<"&F2+1,B2:B500,"East")
Excel 365 / Google Sheets with FILTER (works in both)Formula
=SUM(FILTER(C2:C500,(A2:A500>=F1)*(A2:A500<F2+1)))

Keep F1 and F2 as plain dates without a time. If someone types 10/31/2026 5:00 PM into the end cell, the range stops at 5 PM the next day; INT(F2)+1 instead of F2+1 guards against that.

Month, week and "last 7 days" totals

The same pattern, start on or after the first moment and before the first moment of the next period, makes period totals easy and never misses an end-of-day entry:

Whole month of whatever date is in F3 (any day of the month works)Formula
=SUMIFS(C2:C500,A2:A500,">="&EOMONTH(F3,-1)+1,A2:A500,"<"&EOMONTH(F3,0)+1)
Monthly summary table: first-of-month dates in E2 down, fill this downFormula
=SUMIFS(C$2:C$500,A$2:A$500,">="&E2,A$2:A$500,"<"&EDATE(E2,1))
Last 7 days including todayFormula
=SUMIFS(C2:C500,A2:A500,">="&TODAY()-6,A2:A500,"<"&TODAY()+1)
A fixed range written into the formula: use DATE, not typed date textFormula
=SUMIFS(C2:C500,A2:A500,">="&DATE(2026,10,1),A2:A500,"<"&DATE(2026,11,1))

Typed dates inside the quotes, like ">=10/1/2026", depend on the file's locale and break when someone in another country opens the file. DATE(year,month,day) works everywhere.

Total is 0? Check the criteria and the dates

Good to know

Formulas follow documented Google Sheets / Excel behavior; they aren't machine-tested, so try them on a copy first. Always try new automations on a copy of your sheet first.