# Count birthdays by month in Excel

This tutorial show **how to Count birthdays by month in Excel** using the example below.

To count the number of birthdays in a list, you can use a formula based on the SUMPRODUCT and MONTH functions.

## Formula

=SUMPRODUCT(--(MONTH(birthday)=number))

## Explanation of how this formula works

In the example shown, E5 contains this formula:

=SUMPRODUCT(--(MONTH(birthday)=D5))

This formula counts birthdays in January (since D5 contains 1) in the named range “birthdays” (B5:B104).

You would think you could use the COUNTIF function to count birthdays, but the trouble is COUNTIF only works with ranges, and won’t let you use something like MONTH to extract just the month number from dates. So, we use SUMPRODUCT instead.

Inside SUMPRODUCT, we have this expression:

MONTH(birthday)=D5)

The MONTH function extracts the month for each date in the named range “birthdays”, and this is compared to the value in D5, which is 1. The result is an array of TRUE / FALSE values where each TRUE represents a date where month=1.

The TRUE FALSE values are then converted to ones and zeros with the double negative (–). SUMPRODUCT then sums these numbers and returns a final result.

### Dealing with empty cells

If you have blank cells in the list of birthdays, you will get incorrect results, since MONTH (0) returns 1. To handle blank cells, you can adjust the formula as follows:

=SUMPRODUCT((MONTH(birthdays)=D5)*(birthdays<>""))

Multiplying by the expression (birthdays<>””) effectively cancels out month values for empty cells.