We don’t care at all about the day.

The result is that each date in column D is tested against the date in cell B5.

When the test returns TRUE, the IF function returns “x”.

Excel formula: Date is same month

When the test returns FALSE, IF returns an empty string ("").

This formula does the job and works fine.

However, with a bit of creativity, we can streamline things quite a lot.

Excel formula: Highlight dates in same month and year

Let’s see what we can do to shorten things up a bit.

Then, we use AND to evaluate the two results.

Can we compare year and month in one step and eliminate AND?

Excel formula: Get same date next month

We’ve reorganized the functions because we want the year and month for each date together.

Because we are testing the year and month in one step, we no longer need the AND function.

We combine the values withconcatenationusing the ampersand (&), creating a text string.

Excel IF function

For example, for a date in October 2024, we’ll end up with “102024”.

Can we take this idea further and streamline the formula even more?

The logical test looks like this:

How can we take this idea further and make the formula shorter?

Excel AND function

The TEXT function returns a number formatted as text.

The format itself is provided as an argument calledformat_text.

We’ve reduced function calls by more than half.

Excel MONTH function

It’s also a great demonstration of the versatility of theTEXT function.

More than one condition can be tested by nesting IF functions.

AND returns TRUEonly if all the conditions are met.

Excel YEAR function

If any conditions are not met, the AND function returns FALSE.

TEXT Function

The Excel TEXT function returns a number formatted as text.

in a text string with the number format of your choice.

Excel TEXT function