Formula to calculate time

asad

Well-known Member
Joined
Sep 9, 2008
Messages
1,434
Hi Guys,

I am a bit confused as to how can I calculate time in the following cases. I need to calculate time worked before 5:00 and after 19:00 for the given shift start and end times along with the meal break times.

[TABLE="width: 495"]
<colgroup><col span="6"><col></colgroup><tbody>[TR]
[TD]Start[/TD]
[TD]Meal Start[/TD]
[TD]Meal End[/TD]
[TD]Meal Start[/TD]
[TD]Meal End[/TD]
[TD]Finish[/TD]
[TD]Expected Answer[/TD]
[/TR]
[TR]
[TD]03:57[/TD]
[TD]08:34[/TD]
[TD]09:26[/TD]
[TD]11:04[/TD]
[TD]11:56[/TD]
[TD]13:44[/TD]
[TD="align: right"]01:03[/TD]
[/TR]
[TR]
[TD]13:46[/TD]
[TD]15:34[/TD]
[TD]16:26[/TD]
[TD]19:04[/TD]
[TD]19:50[/TD]
[TD]22:59[/TD]
[TD="align: right"]03:13[/TD]
[/TR]
</tbody>[/TABLE]

Thanks for your help.

Asad
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
05:00 minus 03:57 = 01:03 which is your expected answer as per you example, what do you expect the answer to be?
 
Upvote 0
05:00 minus 03:57 = 01:03 which is your expected answer as per you example, what do you expect the answer to be?
That one works if there are no meal breaks within that time. Look at the second example. How much comes to using your formula?
 
Upvote 0
I forgot about my query but today I was working on it and worked out the formula that fits the criteria and gives correct answer. If someone wants it, here's how I did it.
I used two cells - I1 and J1 to enter the values 5:00 and 19:00.
Then I used this formula
Code:
=($I$1-MIN(A2,$I$1))+(F2-MIN(F2,$J$1))-(MAX($J$1,E2)-$J$1)+(MAX($J$1,D2)-$J$1)
It has worked for me. If someone can give me a better formula, please do so. I am always open to suggestions to learn more.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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