Counting hours in 2 cells but only counting whether they are in a range or not

lisaspencer

New Member
Joined
Jul 20, 2020
Messages
21
Office Version
  1. 365
Platform
  1. MacOS
I am trying to create a work hours spreadsheet and I will be working some hours at a particular rate and other hours on a higher rate.
For example, if I work from 11:00pm Thursday to 7:00am Friday, I get paid £12 p/h for any hours worked between 12:00am and 6:00am, and a £10 p/h rate for any other hours. So when putting the start time and end time in my spreadsheet I would like a formula that will count the hours IF any hours fall into the £10 p/h rate from 6:00am to 12:00am, and another cell formula IF any hours fall into the £12 p/h rate from 12:00am to 6:00am.

any help would be great please!
 

Attachments

  • Screenshot 2020-10-29 at 16.36.37.png
    Screenshot 2020-10-29 at 16.36.37.png
    121.9 KB · Views: 8

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try this:

Book1
BCDE
1Start TimeFinish timeTotal Hours (£10)Total Hours (£12)
210/22/2020 0:0010/22/2020 2:0002
310/22/2020 23:0010/23/2020 7:0026
410/24/2020 0:0010/24/2020 18:00126
Sheet2
Cell Formulas
RangeFormula
D2:D4D2=(C2-B2)*24-E2
E2:E4E2=(MAX(0,MIN(C2,INT(C2)+6/24)-MAX(B2,INT(C2)))+IF(DAY(B2)<>DAY(C2),MAX(0,MIN(C2,INT(B2)+6/24)-MAX(B2,INT(B2)))))*24


It's likely that you can shorten the E2 formula to

Excel Formula:
=MAX(0,MIN(C2,INT(C2)+6/24)-MAX(B2,INT(C2)))*24

It just depends on how long the shifts can be, and how many days could be in the mix.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

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