How to sum values by month
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)Total a column of dated amounts for one month — monthly spend, sales, or hours.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =SUMPRODUCT((MONTH(A2:A5)=7)*(YEAR(A2:A5)=2026)*B2:B5) | Or SUMIFS with date bounds: =SUMIFS(B:B,A:A,">="&DATE(2026,7,1),A:A,"<"&DATE(2026,8,1)). |
| Google Sheets | =SUMPRODUCT((MONTH(A2:A5)=7)*(YEAR(A2:A5)=2026)*B2:B5) | Identical; the SUMIFS date-bounds form also works. |
| LibreOffice Calc | =SUMPRODUCT((MONTH(A2:A5)=7)*(YEAR(A2:A5)=2026)*B2:B5) | Identical. |
How it works
MONTH extracts 1–12 from each date, the comparison makes a 1/0 array, and SUMPRODUCT uses it to keep only July rows: here the two July dates carry 100 + 25 = 125. (In the verified example the dates are raw serial numbers — 46204 is July 1, 2026 — which is exactly what a formatted date cell contains underneath.) Include the YEAR test when data spans years, or use the SUMIFS date-range form, which is faster on big columns and doesn't need array evaluation.
Verified, not just documented
We ran =SUMPRODUCT((MONTH(A2:A5)=7)*B2:B5) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 125 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 125 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.
Functions used
SUMPRODUCT · MONTH · YEAR — see full Excel, Google Sheets & LibreOffice compatibility for each.
Related recipes
- How to create a quarter-and-year label like "Q3 2026"
- How to get the quarter-end date for any date
- How to check if a cell contains any word from a list
- How to check if a year is a leap year
- How to count cells that contain errors