Check if a time range falls within a range

i have a question

New Member
Joined
Oct 27, 2021
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Hey all,

i have a complicated question.

I need to calculate an employees pay based on the time they have worked.
Basically, the employee is paid a meal allowance if they work during a said period of time.

07:30-08:30(breakfast)=25$
12:30-13:30(lunch)=25$
19:30-20:30(dinner)=25$
23:59>(overnight)=15$

the employees starts to work at 14:00 and ends work at 00:15 the next day. So during this time the employee is entitled for a lunch,dinner and overnight. I need a formula to add these values if the employee worked between the start to the end time.

thanks a lot in advance
 

Attachments

  • temp.jpg
    temp.jpg
    48.7 KB · Views: 10
The second "MOD" if it is applying to when lunch or dinner starts won't matter, so no need to change it.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
This could also work.
MrExcelPlayground4.xlsx
ABC
37:30 AM8:30 AM$ 25.00
412:30 PM1:30 PM$ 25.00
57:30 PM8:30 PM$ 25.00
611:59 PM$ 15.00
7
8Start TimeEnd Time
910/27/2021 14:0010/28/2021 0:15$ 40.00
1010/27/2021 7:0010/27/2021 16:00$ 50.00
1110/27/2021 8:0010/27/2021 17:00$ 25.00
1210/27/2021 9:0010/27/2021 18:00$ 25.00
1310/27/2021 10:0010/27/2021 19:00$ 25.00
1410/27/2021 11:0010/27/2021 20:00$ 25.00
1510/27/2021 12:0010/27/2021 21:00$ 50.00
1610/27/2021 13:0010/27/2021 22:00$ 25.00
1710/27/2021 14:0010/27/2021 23:00$ 25.00
1810/27/2021 15:0010/28/2021 0:00$ 40.00
Sheet25
Cell Formulas
RangeFormula
C9:C18C9=IF(AND(A9<=INT(A9)+$A$3,IF(B9<A9,B9+1,B9)>=INT(A9)+$B$3),$C$3,0)+IF(AND(A9<=INT(A9)+$A$4,IF(B9<A9,B9+1,B9)>=INT(A9)+$B$4),$C$4,0)+IF(AND(A9<=INT(A9)+$A$5,IF(B9<A9,B9+1,B9)>=INT(A9)+$B$5),$C$5,0)+IF(AND(A9<=INT(A9)+$A$6,IF(B9<A9,B9+1,B9)>=INT(A9)+$A$6),$C$6,0)
A11:B18A11=A10+1/24
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,239
Members
448,555
Latest member
RobertJones1986

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