The core of the problem is to compare the given birthday to the current date while ignoring the year.
There are two main ways to approach the problem.
This works fine, but the formula is a bit more complex.
This solution is a bit more elegant.
Both methods are described below.
MONTH returns 5 for a date in May) .
TheDAY functionreturns the day portion of a date.
TheTODAY functionreturns the current date.
Essentially, the logical expressions inside the AND function check to see if the month and day both match.
We purposely ignore the year for birthdays, since the year only matches in the first year of birth.
When AND returns TRUE,the IF function will return “Happy Birthday!”
This formula works fine, but the TEXT function can streamline the formula somewhat, as explained below.
TEXT function
TheTEXT functioncan also be used to solve this problem in a more elegant way.
The TEXT function is used to applycustom number formatsinside a formula.
The logical test returns TRUE and the IF function returns “Happy Birthday!”
in a text string with the number format of your choice.
The TODAY function takes no arguments.
it’s possible for you to format the value returned by TODAY with a datenumber format.
More than one condition can be tested by nesting IF functions.
AND returns TRUEonly if all the conditions are met.
If any conditions are not met, the AND function returns FALSE.