[英]Excel formula - find if any date in a given range matches a given year
I have a table listing work anniversaries, looking something like:我有一张列出工作周年纪念日的表格,看起来像:
5 years | 10 years | 15 years | 20 years... etc
27/1/2011 | 27/1/2016 | 27/1/2021 | 27/1/2026.. etc
I would like to check if any of the dates falls within the current year.我想检查是否有任何日期在当年之内。 I can do it easily enough with a formula such as =OR(year(cell1)=2021,year(cell2)=2021.. etc
but it's not particularly elegant. What would be a better way to do it?我可以使用=OR(year(cell1)=2021,year(cell2)=2021.. etc
公式轻松做到这一点,但它并不是特别优雅。有什么更好的方法来做到这一点?
Use COUNTIFS:使用 COUNTIFS:
=COUNTIFS(A2:F2,">="&DATE(2021,1,1),A2:F2,"<"&DATE(2022,1,1))>0
A2:F2
being the dates to test A2:F2
是测试的日期
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.