# Number of working hours between two times

#### ramble_boy

##### New Member
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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use \$ signs: \$V\$2:\$Z\$99 will always point to V2:Z99, even after copying
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

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

Replies
3
Views
601
Replies
4
Views
179
Replies
12
Views
569
Replies
1
Views
282
Replies
3
Views
666

Threads
1,219,695
Messages
6,149,775
Members
450,913
Latest member
mdsuther

### 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

### 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