Calculate amount of time between two times and deduct 30-minutes

mavsounds

New Member
Joined
Mar 2, 2017
Messages
9
Hi,

I'm building a shift schedule for a restaurant.

I want to have one cell with start time, one cell with end time, and one cell with duration. However, I want the duration to automatically subtract a 30-minute unpaid meal-period. I found an old thread with the formula below. It works great. But, I want to add one condition that it duration returned value is the actual duration if the total duration is less than 5 1/2 hours. I can't figure that "if" statement. Any ideas?

=(M10-L10+IF(MOD(M10-L10,1)<0.5,(M10>L10),-(M10>L10)))-TIME(0,30,0)
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
=(M10-L10+IF(MOD(M10-L10,1)<0.5,(M10>L10),-(M10>L10)))-TIME(0,30,0)

I don't think I understand the purpose of the IF statement in this formula. The modulus division result of any decimal divided by 1 will be the decimal itself. For example, if L10=8:00 and M10=21:00, the result is a negative number (surely not what you want). Is it intended to cover overnight shifts? Can you post some examples of L10 and M10 values where this works correctly? Or, do you have a link to the original thread where you found this?

it duration returned value is the actual duration if the total duration is less than 5 1/2 hours. I can't figure that "if" statement. Any ideas?
Not sure what you mean by this, either (maybe I am having a slow moment - bear with me :) ). What is "actual duration" vs "total duration"? Do you mean that is the shift is shorter than 5 1/2 hours, you do not subtract the 30 minutes?

Would this work for you?
Code:
=(M10+(L10>M10)-L10) - TIME(0,30,0)*(((M10+(L10>M10))-L10)>TIME(5,30,0))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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