You can use the following formula to use an IF function based on a month in Excel:

=IF(MONTH(A2)=2, B2, 0)

This particular formula checks if the month in the date of cell **A2** is equal to **2**, e.g. February.

If the month is February, then the formula returns the value in cell **B2**.

Otherwise, the formula simply returns a value of **0**.

The following example shows how to use this formula in practice.

**Example: Use IF Function Based on Month in Excel**

Suppose we have the following dataset in Excel that contains information about sales on various dates for some retail store:

Suppose we would like to use an IF function that returns the value of the sales if the date in column A is in February or a value of zero if the date is not in February.

We can type the following formula into cell **C2** to do so:

If the date in column A is in February, then the formula returns the corresponding value in the sales column.

Otherwise, the formula simply returns a value of zero.

Note that you can also use multiple conditions within the IF function.

For example, you can use the following formula to return the value of the sales if the date in column A is in February **or **March, otherwise a value of zero:

=IF(OR(MONTH(A2)=2, MONTH(A2)=3), B2, 0)

The following screenshot shows how to use this formula in practice:

If the date in column A is in February or March, then the formula returns the corresponding value in the sales column.

Otherwise, the formula simply returns a value of zero.

**Additional Resources**

The following tutorials explain how to perform other common tasks in Excel:

Excel: How to Use IF Function with Multiple Conditions

Excel: How to Create IF Function to Return Yes or No

Excel: How to Use an IF Function with Range of Values