Number of working hours between two times

ramble_boy

New Member
Joined
Sep 25, 2006
Messages
2
Hi there,

I'm having a problem in Excel 2002. I have two columns with dates and times in (a 'start date & time' and an 'end date & time') and need to calculate the number of working hours between the start and end date/times. Working times are set (8am - 7:30pm) and weekends and bank holidays should not be included (as in the 'networkdays' function). For example, if the start time was 22/09/06 14:00 and the end time was 25/09/06 10:20, the result I would be looking for would be 07:50 or "7hrs 50 minutes". Actually, it would be useful to have it as a straight 'number of hours' - 7.83(ish) hours in the example above.

The start and end times are not necessarily within the working hours, and might even be on weekends or bank holidays (so if start and end times were on the same weekend, there would be zero working hours between them).

If anyone can help it would be much appreciated.

Many thanks in advance,
Ramble_boy
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
hi ramble_boy, welcome to the board.

This is a little tricky when your times can be at weekends or evenings but this formula should accommodate that

=((NETWORKDAYS(A3,B3)-1)*(J$4-J$3)+IF(NETWORKDAYS(B3,B3),MEDIAN(MOD(B3,1),J$4,J$3),J$4)-IF(NETWORKDAYS(A3,A3),MEDIAN(MOD(A3,1),J$4,J$3),J$3))*24

format as general

where A3 contains start date/time, B3 contains end date/time, J3 contains weekday start time, e.g. 08:00 and J4 contains weekday finish time, e.g. 19:30.

If you want a holiday range then list those somewhere on the worksheet and include as the 3rd argument of each of the NETWORKDAYS functions
 

ramble_boy

New Member
Joined
Sep 25, 2006
Messages
2
Thanks very much Barry, that looks like exactly what I'm looking for. I've just slotted it into one of my spreadsheets and it seems to be working perfectly.

Thanks again,
Ramble_boy
 

Forum statistics

Threads
1,171,579
Messages
5,876,290
Members
433,192
Latest member
butterexcel

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
Top