Calculating net work hours allowing for holidays, start and finish times and lunch times

HGSRWF

New Member
Joined
Jun 7, 2018
Messages
2
I am trying to calculate net work hours between two dates and times using formula shown below. Complete example workbook can be downloaded here. Formula shown below correctly leaves out weekends and holidays, takes into account start and end times, but will not calculate when work time is over lunch time and deduct that time off.

<starttime,b2<a2),0,(networkdays(a2,b2,holidaylist)-(networkdays(a2,a2,holidaylist)*if(mod(a2,1)><starttime,1,(endtime-min(endtime,mod(b2,1))) (endtime-starttime))))*(endtime-starttime)*24)
<starttime,b2<a2),0,(networkdays(a2,b2,holidaylist)-(networkdays(a2,a2,holidaylist)*if(mod(a2,1)><starttime,1,(endtime-min(endtime,mod(b2,1))) (endtime-starttime))))*(endtime-starttime)*24)]
=IF(OR(EndTime<StartTime,B2<A2),0,(NETWORKDAYS(A2,B2,HolidayList)-(NETWORKDAYS(A2,A2,HolidayList)*IF(MOD(A2,1)>EndTime,1,(MAX(StartTime,MOD(A2,1))-StartTime)/(EndTime-StartTime)))-(NETWORKDAYS(B2,B2,HolidayList)*IF(MOD(B2,1)<StartTime,1,(EndTime-MIN(EndTime,MOD(B2,1)))/(EndTime-StartTime))))*(EndTime-StartTime)*24)

Details for this formula are:

  1. A2 contains start date and time
  2. B2 contains end date and time
  3. StartTime is named range for daily start time (7:00 AM)
  4. EndTime is named range for daily end time (3:30 PM)
  5. HolidayList is named range for public holiday dates
  6. StartTimeLunch is named range for daily lunch start time, not used in formula yet (12:00 PM)
  7. EndTimeLunch is named range for daily lunch end time, not used in formula yet (12:30 PM)
  8. Result shown in decimal format
</starttime,1,(endtime-min(endtime,mod(b2,1)))></starttime,b2<a2),0,(networkdays(a2,b2,holidaylist)-(networkdays(a2,a2,holidaylist)*if(mod(a2,1)></starttime,1,(endtime-min(endtime,mod(b2,1)))></starttime,b2<a2),0,(networkdays(a2,b2,holidaylist)-(networkdays(a2,a2,holidaylist)*if(mod(a2,1)>
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,224,828
Messages
6,181,210
Members
453,023
Latest member
alabaz

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