Duration Formula

kizzie37

Well-known Member
Joined
Oct 23, 2007
Messages
585
Office Version
  1. 365
I have the below Date & time in cell a1 and another date and time in cell a3

8/2/2010 08:45:00
8/2/2010 10:15:00


I need to be able to show duration (in hours) between the 2 times, in this instance its the same date, but this wont always be the case. To add a level of complexity in addition to the gross duration in hours, I will also need to know how long (in hours or mins) of the duration fits into "in hours" ( 9 -5 mon- fri) then the duration thats fits "out of hours" (after 5pm weekdays or all day Sat & Sun)

Appreciate this wont be all in one formula but can anyone suggest how to work through this Please
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You could use = B1-A1 and format the cell with the custom format [h]

If you need the number of hours returned =ROUND(24*(B1-A1),0) should do it.
 
Upvote 0
thanks mikerickson, but how does this work with the difference in dates and the in and out of hours requirement
 
Upvote 0
I missed that you posted the cell locations in the OP,
Try = A3-A2

about in/out hours, will there ever be a case where both ends of the interval are IN, but an OUT period exists in side.

eg Monday 3PM to Tuesday 2PM (with overnight OUT inside the inverval)
 
Last edited:
Upvote 0
Try;

=(INT(B1)-INT(A1))*(17-9)/24+MEDIAN(0,(17-9)/24,MOD(B1,1)-9/24)-MEDIAN(0,MOD(A1,1)-9/24,(17-9)/24)

for the 'in' hours...

Edit:

'Out' hours = B1-A1-C1
where C1 is the result of the first formula above...
 
Last edited:
Upvote 0
Can the start time be on a Friday and the end time on a Monday or similar? In that case you'd have to include NETWORKDAYS function.

Will start time/date and end time/date always be within working hours?
 
Upvote 0

Forum statistics

Threads
1,223,262
Messages
6,171,080
Members
452,377
Latest member
bradfordsam

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