# Excel: How to Check if Month and Year Match Between Dates

You can use the following formula to check if the month and year match between two dates in Excel:

```=MONTH(A2)&YEAR(A2)=MONTH(B2)&YEAR(B2)
```

This particular formula checks if the month and year in cell A2 match the month and year in cell B2 and returns either TRUE or FALSE.

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

## Example: Check if Month and Year Match Between Dates

Suppose we have the following two lists of dates in Excel: We can type the following formula into cell C2 to check if the month and year match between the dates in cells A2 and B2:

`=MONTH(A2)&YEAR(A2)=MONTH(B2)&YEAR(B2)`

We can then click and drag this formula down to each remaining cell in column C: Column C returns either TRUE or FALSE to indicate if the month and year matches between the corresponding cells in columns A and B.

Note that you could also use the following formula to return “Match” or “Do Not Match” instead of TRUE or FALSE if you’d like:

`=IF(MONTH(A2)&YEAR(A2)=MONTH(B2)&YEAR(B2), "Match", "Do Not Match")`

The following screenshot shows how to use this formula in practice: Column C now returns either Match or Do Not Match to indicate if the month and year matches between the corresponding cells in columns A and B.

## How This Formula Works

Recall the formula we used to check if the month and year matched between the dates in cells A2 and B2:

`=MONTH(A2)&YEAR(A2)=MONTH(B2)&YEAR(B2)`

Here is how this formula works:

We use the MONTH and YEAR functions to extract the month and year for each cell and then use the & symbol to concatenate these values together.

For example, MONTH(A2)&YEAR(A2) returns 12023 for cell A2.

Then, MONTH(B2)&YEAR(B2) returns 12023 for cell B2.

Thus, MONTH(A2)&YEAR(A2)=MONTH(B2)&YEAR(B2) returns TRUE since 12023=12023.

This same logic is used to check if the month and year for each corresponding cell in columns A and B matches.