Compare month and day (not year) in Excel

Clash Royale CLAN TAG#URR8PPP
Compare month and day (not year) in Excel
'Worksheet1'!A2 contains a date.
'Worksheet1'!A2
If the month and day of A2 are between 0 and 7 days after today's month and day, I want B2 to equal A2. Otherwise, B2 should equal "".
A2
B2
A2
B2

In other words, ignoring the years, if the month and day of A2 are within 7 days of today, I want B2 to display A2 with the year being the same as the current year. Otherwise, I want B2 to display nothing.
A2
B2
A2
B2
1 Answer
1
then just subtract the date as if it is this year and check discrepancy.
=IF(OR(DATE(YEAR(TODAY()),MONTH(A2),DAY(A2))-TODAY()=0,1,2,3,4,5,6,7),A2,"")

A2
=IF(OR(DATE(YEAR(TODAY()),MONTH(A2),DAY(A2))-TODAY()=0,1,2,3,4,5,6,7),DATE(YEAR(TODAY()),MONTH(A2),DAY(A2)),"")
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Great solution, Scott! Dusty, if you want
A2to have the same year as the current year, use=IF(OR(DATE(YEAR(TODAY()),MONTH(A2),DAY(A2))-TODAY()=0,1,2,3,4,5,6,7),DATE(YEAR(TODAY()),MONTH(A2),DAY(A2)),""). I may have I misinterpreted that part of your question, though.– TotsieMae
Aug 7 at 21:52