Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

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?

question from:https://stackoverflow.com/questions/65910358/excel-formula-find-if-any-date-in-a-given-range-matches-a-given-year

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use COUNTIFS:

=COUNTIFS(A2:F2,">="&DATE(2021,1,1),A2:F2,"<"&DATE(2022,1,1))>0

A2:F2 being the dates to test


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...