Home > Software design >  Compare to dates to see if day of the month falls between them in excel
Compare to dates to see if day of the month falls between them in excel

Time:11-15

I'd like to know how I can write a function to check if the 15th day of the month falls within two days. For instance the first field in column b would check to see if the 15th day of the month falls within the first 2 fields in column A. If so (like in this case) it would print true.

Column A Column B
01-06-23 True
01-20-23 False
02-03-23

I'm trying with using wildcards, but evidently it's not as simple as that.

=IF("**-15-**">=A2,IF("**-15-**"<=A3,"True","False"),"False")

CodePudding user response:

Dates are stored as doubles and not a string, so you need to test the day of the month using DAY():

=SUMPRODUCT(--(DAY(SEQUENCE(A3-A2 1,,A2))=15))>0

This iterates the dates and checks if any are the 15th.

enter image description here

  • Related