简体   繁体   中英

Excel formula to calculate intersected dates?

I searched through internet and came up with nothing. I have two tables. one includes work dates and the other has vacation dates. I have to find the intersected dates.

Let me give an example;


1|  A    |      B             |       C          |          D
2|Person |    Work Start Date | work finish Date |Intersected Vacations
3|Mike   |         01.08.2013 |       10.08.2013 |1  (Needed to find)
4|John   |         16.08.2013 |       25.10.2013 |3  (Needed to find)


1|A      |B                   |C
2|Person |Vacation Start Date |Vacation End Date
3|Mike   |         05.08.2013 |       05.08.2013
4|John   |         20.09.2013 |       21.09.2013
5|John   |         01.10.2013 |       01.10.2013

So, I need an excel formula to calculate the vacations between the work days.

Assuming you are counting all days within the periods, including Saturdays and Sundays you can use this "array formula" as per my screenshot below:

Formula is as follows in D3:

=SUM(IF(A$8:A$10=A3,IF(C$8:C$10>=B3,IF(B$8:B$10<=C3,IF(C$8:C$10>C3,C3,C$8:C$10)-IF(B$8:B$10<B3,B3,B$8:B$10)+1))))

confirmed with CTRL + SHIFT + ENTER and copied down to D4

This may look like overkill for your small example but I'm assuming your real data is larger - this solution can be extended as required, even for multiple unsorted vacation periods

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM