Calculate hours within 2 date/time

Pantoffsky

New Member
Joined
Jan 26, 2016
Messages
14
Office Version
  1. 2019
Platform
  1. Windows
Hi,
I've been struggling with the following:

I have 2 lines with 2 timeslots, let's say:

A2= 2022-01-03 21:30
B2= 2022-01-04 07:30

A3= 2022-01-04 21:30
B3= 2022-01-04 04:00

To calculate a rate, I need to know how many hours have been worked between 21:00 and 05:00, because they have a different rate.

How do i calculate these "expensive" hours?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
It is much better if you post a concise example with the forum's tool XL2BB.
The example should show the expected result.

try the following

Date and Time 2021.xlsm
ABCDEFG
1TotalOTReg21:0005:00
22022-01-03 21:302022-01-04 07:3010:00:0007:30:0002:30:00
32022-01-03 21:302022-01-04 04:0006:30:0006:30:0000:00:00
12b
Cell Formulas
RangeFormula
C2:C3C2=B2-A2
D2:D3D2=1-MAX(F1,MOD(A2,1))+MIN(G1,MOD(B2,1))
E2:E3E2=C2-D2
 
Upvote 0

Forum statistics

Threads
1,214,810
Messages
6,121,690
Members
449,048
Latest member
81jamesacct

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