Number of days to not include the start date and the end date

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have 2 cells that have a start and an end date in them.

  • B8 is the start date
  • B9 is the end date
  • I have a list of public holiday dates in the range Sheet2!G87:DO97.
I then have some formulas for calculating the number of weekdays, saturdays, sundays and public holidays in the time period.

  • The formula to calculate the weekdays in the period between B8 and B9 is =NETWORKDAYS.INTL(B8,B9,1,Sheet2!G87:DO97)
  • The formula to calculate the satudays is =INT((WEEKDAY($B$8- 7)-$B$8+$B9)/7)
  • The formula to calculate the sundays is =INT((WEEKDAY($B$8- 1)-$B$8+$B9)/7)
  • The formula to calculate the public holidays is =SUMPRODUCT((Sheet2!G87:DO97>=B8)*(Sheet2!G87:DO97<=B9))

I need the formulas to not count the start and the end date as at the moment, the formulas include the start and end dates.

Can someone help me adjust the formulas so they do not count the start or end dates in the calculation please?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
The easiest way would be to use StartDate+1 and EndDate-1 in your formulas. I'd use WORKDAY to shift the dates by one but using that would mess up your Sat + Sun calculations.

Not sure what you want to see in cases where the StartDate & EndDate happens to be the same date or following workdays but I'd wrap the original workday calculations in a MAX just to make sure the duration is always at least 1.
 
Upvote 0
Thanks for the reply, I have no idea as to how to write these formulas so any help would be appreciated. I just need them to calculate if there are any of the specific dates in the period, such as weekdays etc. If the start and end date are the same day, the cost will take into account thestart and end times and calculate from there.
 
Upvote 0
If your dates include the time as well you could try something like

=MAX(NETWORKDAYS.INTL(A1+1,B1-1,1,Holidays),0)+MOD(B1-A1,1)

Where
A1 = calculation Start DateTime
B1 = calculation End DateTime and
Holidays = the range where you have the holidays ie. dates excluded from the workdays calculations.

The formula returns the total number of hours on workdays (parameter 1 treats Saturday and Sunday as the weekend) between those two time stamps.

If you want to calculate only the working hours (ie. each full workday is calculated as X hours) you might want to multiply the the MAX-part of the formula with your X. Or split the formula into two separate cells.
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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