Working days during affected months

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Need a formula that counts the number of days that someone's leave will impact. Any approach is fine, I did ask a similar question previously but have changed my formulae for this example.

Book3
ABCDEFGHIJKLMNOPQ
1NameLeave TypeQuantity - DaysStart DateEnd DateJanFebMarAprMayJunJulAugSepOctNovDec
2JackAnnual Leave723/09/20201/10/202061
3MaryAnnual Leave224/01/20204/02/2020
4PeterAnnual Leave84/01/202015/01/2020
Sheet1
Cell Formulas
RangeFormula
C2:C4C2=NETWORKDAYS(D2,E2)


Row 2 shows the desired output in column N & O.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Something like this should work as long as the Start Date and End Date share the same year:
=IF(OR(COLUMNS($F$2:F2)<MONTH($D2),COLUMNS($F$2:F2)>MONTH($E2)),"",NETWORKDAYS(MAX(DATE(YEAR($D2),COLUMNS($F$2:F2),1),$D2),MIN(EOMONTH(DATE(YEAR($D2),COLUMNS($F$2:F2),1),0),$E2)))

The formula compares the number of columns to the month number and when they overlap it calculates the number of working days from MAX(Start of Month, Start Date) to the MIN(End of Month, End Date).

If the month names were actual dates (for example the first of the month) the whole formula could be a lot easier to write (you could compare one date to another) and it would work even if the leave started at the end of one year and ended the next year.
 
Last edited:
Upvote 0
Thank you Misca, perfect! I can't quite follow your last sentence, could you provide an example, it is likely that I will have to work out leave amounts over different years.
 
Upvote 0
F2:Q2 are dates like 01-01-20 formatted as Month

T202009c.xlsm
ABCDEFGHIJKLMNO
1
2NameLeave TypeQuantity - DaysStart DateEnd DateJanFebMarAprMayJunJulAugSepOct
3JackAnnual Leave723-Sep-201-Oct-20        61
4MaryAnnual Leave224-Jan-204-Feb-20202        
5PeterAnnual Leave84-Jan-2015-Jan-208         
1f
Cell Formulas
RangeFormula
F3:O5F3=IF(MONTH(F$2)<MONTH($D3),"",MAX(0,NETWORKDAYS(MAX(F$2,$D3),MIN(EOMONTH(F$2,0),$E3))))
C3:C5C3=NETWORKDAYS(D3,E3)
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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