Determine total numbers of days worked in a given month/year from a table of date ranges

jrob72684

New Member
Joined
May 2, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am looking for help in writing a formula that will query a table and return a sum of all dates worked within a specified month/year. My data has date ranges given with a start date in column A and an end date in column B. Many of the dates cross over multiple months. So far I have been able to successfully return the dates worked when looking at one specific row but I am drawing a blank on how to get excel to look at the whole table and sum the values.

The formula I used to return days worked within a given month/year for one specified row is:
=MAX(0,1+MIN($B2,EOMONTH(E$1&$D2,0))-MAX($A2,EOMONTH(E$1&$D2,-1)+1))

E1 is a cell with a label for January and D2 is a cell with a given year. This formula was then drug across to P2 to test if it worked for the first row of data across all months.

I need a formula that would return this same value but check the entire table's contents and sum total days.

Appreciate any help you can give.
 

Attachments

  • Spreadsheet.JPG
    Spreadsheet.JPG
    162.1 KB · Views: 7

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Welcome to the MrExcel forum!

Try:

Book1
ABCDEFGHIJKLMNOP
1FromToJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
211/7/200711/10/20072007000000000040
33/29/20084/5/20082008003502326279000
46/8/20087/26/200820090000200203130313031
58/5/20089/3/2008201024002313031624313031
69/25/20089/30/2008201122000051800000
710/1/20081/23/2008201217002800000000
85/6/20095/25/20092013000000000000
97/12/20099/30/20092014000000000000
1010/1/20091/24/20102015000000000000
114/29/20108/6/20102016000000000000
129/7/20109/30/20102017000000000000
1310/1/20101/22/20112018000000000000
146/6/20116/10/20112019000000000000
157/8/20117/25/20112020000000000000
161/2/20121/8/20122021000000000000
171/14/20121/23/20122022000000000000
183/19/20213/19/20122023000000000000
194/1/20124/28/20122024000000000000
Sheet3
Cell Formulas
RangeFormula
E2:P19E2=LET(e,EOMONTH(E$1&$D2,0),s,EOMONTH(E$1&$D2,-1)+1,sd,$A$2:$A$19,ed,$B$2:$B$19,a,IF(ed<e,ed,e)+1,b,IF(sd>s,sd,s),SUM(IF(a-b>0,a-b)))
 
Upvote 0
Solution

Forum statistics

Threads
1,216,073
Messages
6,128,641
Members
449,461
Latest member
kokoanutt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top