Occasionally you will need to compare Excel dates for month and year only. So a match happens when the month and year of the two dates are the same ignoring the day of the month. There are many ways to do this including using AND within an IF function, but the most efficient way is to use the EOMONTH function.
Table of contents
YouTube Compare Excel dates based on month and year ONLY
Matching the month/ year an event occurred
As shown below we want to be able to place the amount in the month it occurred where the payment is made on any day within the month and the dates at the top are shown as the first of the month (we always use end of the month, but for this example it is useful to show where both dates can be different in the days).
Use EOMONTH to remove the day being different
The function to include in your IF formula is the EOMONTH function. The EOMONTH function stands for End Of Month and turns any date into a date for the last day of the month. So in the example above, the 16 May 2021 would always change to 31 May 2021 and the 1 May 2021 would always change to 31 May 2021. It is then very easy to compare these 2 dates in an IF.
As shown below the formula is much shorter (and easier to read/ change) than a formula that individually extracts the month and year from both dates and then compares them.