Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Check if date lies between multiple start and end dates

I have a formula to write in Excel that is supposed to check whether any given/entered date falls in one of multiple given time periods, where said time periods are given as "starting date" and "end date", where the "end date" is obviously required to be after the "start date" (or is the same).

Think of it as a check, whether on a date any colleague is on vacation, the time periods being the vacation times.

Now, for only ONE period in my list of periods, this is a no brainer:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

=IF(AND(A1>=B1;A1<=C1);TRUE;FALSE)

(assuming that I enter the date to check in A1 and define periods start/end times in B1/C1 respectively)

Now, for a list of said time periods, I would want to resort to using SQL. Anyhow, is there a nice and easy trick to get this working without too much fuss?

Mock data:

A B C
1 1.5.23 30.4.23 2.5.23
2 7.7.23 7.7.23

(European date format)

The value of A1 lies in the period defined in B1/C1, but not in period B2/C2. The formula should return "true"

>Solution :

Use SUMPRODUCT:

=SUMPRODUCT((A1>=E1:E2)*(A1<=F1:F2))>0

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading