Excel Formula: Calculate overlapping days between two date ranges

doc calculate overtime pay 4

In this tutorial, it provides a formula to calculate the overlapping days between two date ranges in Excel. For example, the first given date range is 1/1/2020-6/20/2020, and the project A is proceeded in the date range 8/16/2019-1/2/2020, there are 2 overlapping days between these two date ranges as above screenshot shown.

If you want to follow along with this tutorial, please download the example spreadsheet.
doc sample

Generic formula:

MAX(MIN(end1,end2)-MAX(start1,start2)+1,0)

Arguments

End1, start1: the end date and start date in the first date range.
End 2, start2: the end date and start date in the second date range.

Return value

The formula returns the overlapping days with a numeric value.

How this formula work

Here the projects are proceeded in different date ranges, we want to calculate the overlapping days between date range of each project and a given fixed date range in Range C2:C3.
doc calculate overlapping days 2

In cell H3, please use below formula:

=MAX(MIN($C$3,G3)-MAX($C$2,F3)+1,0)

Press Enter key then drag autofill handle below to calculate the overlapping days.
doc calculate overlapping days 3

Explanation

MIN function is used to find the minimum value in many values. Here it finds out the earlier date between the two end dates.

MAX function is used to find the maximum value in values.

The inner MAX function finds out the later date between two start dates.

To include both start date and end date, we offset the result by adding 1.

=MAX(MIN($C$3,G3)-MAX($C$2,F3)+1,0)
=MAX(43832-43831+1,0)

The outer MAX function is used to display the negative value instead of zero.


Relative Formulas

Relative Functions


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.