To use SUMIF with dates, you combine the SUMIF function with logical operators (such as >, <, or <>) and a date formatted as a string or a cell reference. For example, to sum values where the date is after January 1, 2023, you would use the formula =SUMIF(A:A, ">1/1/2023", B:B), where column A contains the dates and column B contains the values to be summed.
How Date Logic Works in Spreadsheets
Understanding how to sum by date requires a fundamental grasp of how spreadsheet software like Microsoft Excel and Google Sheets handles time. To a human, a date looks like "December 4, 2026," but to the software, it is actually a sequential serial number. This system typically begins on January 1, 1900, which is assigned the value 1. Every day after that increments the number by one. Because dates are stored as numbers, the SUMIF function can perform mathematical comparisons (greater than or less than) just as it would with integers.
The primary challenge when using SUMIF with dates is the syntax of the criteria. The criteria argument in a SUMIF function must be a string if it includes a logical operator. This means that if you want to find dates after a certain point, the operator and the date must be enclosed in quotation marks. If you are referencing a cell that contains a date, you must use the ampersand (&) symbol to concatenate the operator with the cell reference, such as ">"&C1.
Step-by-Step Implementation for Common Scenarios
Depending on your goal, the way you structure your SUMIF formula will change. Here are the most common ways to implement date-based summing:
- Summing values after a specific date: To sum all values in column B where the date in column A is later than a specific date, use
=SUMIF(A:A, ">12/31/2023", B:B). Ensure the date format matches your regional settings (MM/DD/YYYY vs DD/MM/YYYY). - Summing values before a specific date: To sum values occurring before a certain cutoff, use the less-than operator:
=SUMIF(A:A, "<1/1/2024", B:B). - Summing values for a specific single day: If you only want the total for one exact date, you do not need a logical operator. You can simply use
=SUMIF(A:A, "1/1/2024", B:B)or reference a cell:=SUMIF(A:A, C1, B:B). - Summing values based on a cell reference: To make your sheet dynamic, put your target date in cell C1 and use
=SUMIF(A:A, ">="&C1, B:B). This allows you to change the date in C1 without editing the formula itself.
Summing Between Two Dates with SUMIFS
A common limitation of the standard SUMIF function is that it only supports one condition. If you need to sum values that fall between two dates—for example, everything in the month of March—you must upgrade to the SUMIFS function. SUMIFS allows for multiple criteria ranges and criteria.
To sum values between March 1, 2024, and March 31, 2024, the formula would look like this: =SUMIFS(B:B, A:A, ">=3/1/2024", A:A, "<=3/31/2024"). Note that in SUMIFS, the sum_range (column B) comes first, whereas in SUMIF, it comes last. This structural difference is a frequent source of errors for users switching between the two functions.
Using SUMIFS is the most reliable way to create monthly or quarterly reports. By setting a start date and an end date in two separate cells (e.g., E1 and E2), you can create a flexible report: =SUMIFS(B:B, A:A, ">="&E1, A:A, "<="&E2). This method prevents the need to manually rewrite formulas every time a new reporting period begins.
Common Problems and Troubleshooting
When a SUMIF date formula returns 0 or an incorrect value, it is usually due to data formatting rather than a logic error in the formula. Here are the most frequent issues:
- Dates Stored as Text: This is the most common problem. If a date was imported from a CSV or another software, it might look like a date but be stored as a text string. Since SUMIF relies on the serial number of the date, it cannot perform "greater than" or "less than" operations on text. To fix this, select the column, go to the Data tab, use "Text to Columns," and select "Date" in the final step to convert them to true date values.
- Hidden Time Stamps: Some systems export dates with a time stamp (e.g., 1/1/2024 14:30). If you use the criteria
"=1/1/2024", the spreadsheet looks for exactly 1/1/2024 at midnight. Any value with a time attached will be ignored. To solve this, use a range (greater than or equal to the start of the day and less than the start of the next day). - Regional Date Conflicts: If you use a US-style date (MM/DD/YYYY) in a workbook set to UK regional settings (DD/MM/YYYY), the formula may either return an error or sum the wrong dates. The safest way to avoid this is to reference a cell containing a date or use the DATE function inside the formula, such as
">="&DATE(2024,1,1). - Incorrect Range Sizes: In SUMIF and SUMIFS, the criteria range and the sum range must be the exact same size. If your criteria range is A1:A100 but your sum range is B1:B101, the formula will return a #VALUE! error.
Comparing SUMIF to Other Date-Summing Alternatives
While SUMIF is efficient for simple tasks, other tools may be more appropriate depending on the volume of data and the complexity of the analysis.
Pivot Tables: For those who need to sum dates by month, quarter, or year across thousands of rows, Pivot Tables are superior to SUMIF. Pivot Tables have a built-in "Group" feature that allows you to right-click a date column and instantly group the data into months or years without writing a single formula. This eliminates the need for multiple SUMIFS formulas for every month of the year.
SUMPRODUCT: The SUMPRODUCT function is more versatile than SUMIF because it can handle arrays and perform calculations on the fly. For example, if you want to sum values for all "Januarys" regardless of the year, SUMPRODUCT can wrap the date range in a MONTH function: =SUMPRODUCT((MONTH(A1:A100)=1)*B1:B100). This is impossible with a standard SUMIF because SUMIF requires a direct range and cannot apply a function to the range before evaluating the criteria.
Filter and Subtotal: For quick, one-time analysis, using the Filter tool to select specific dates and then using the =SUBTOTAL(109, B:B) function is often faster than building a formula. SUBTOTAL(109, ...) only sums the visible rows, meaning as you filter the dates, the total updates automatically.
Frequently Asked Questions
Why is my SUMIF date formula returning zero?
The most likely cause is that your dates are formatted as text rather than true date values. You can check this by selecting a date cell and changing the format to "Number"; if the date does not change to a five-digit serial number (like 45291), it is text. Use the Text-to-Columns tool to convert the column to dates.
Can I use SUMIF to sum dates for the current month?
Yes, but it requires a dynamic formula. You can use =SUMIFS(B:B, A:A, ">="&EOMONTH(TODAY(),-1)+1, A:A, "<="&EOMONTH(TODAY(),0)). This uses the EOMONTH function to automatically calculate the first and last day of the current month based on today's date.
Does SUMIF work the same in Google Sheets and Excel?
Yes, the basic syntax for SUMIF and SUMIFS is identical in both programs. Both treat dates as serial numbers and use the same concatenation method (using the ampersand) to join logical operators with cell references.
How do I sum values that are NOT a certain date?
You can use the "not equal to" operator, which is represented by <>. For example, to sum everything except for values on January 1, 2024, use =SUMIF(A:A, "<>1/1/2024", B:B).
Can I sum by date using a partial match?
No, you cannot use wildcards (like *) with dates because dates are numbers, not text. Wildcards only work on text strings. To sum by a partial date (like all dates in a specific year), you must use a range with SUMIFS (from January 1 to December 31) or use a helper column to extract the year first.