Errors after midnight in formula calculation

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello All,

I am having an issue with accurately counting hours worked. Now, my formulas all work fine until the ending point of a shift reaches the AM. For Example: 6PM - 1AM would be a 7 hour shift, but the result is negative 17 hours. Now I am using two different set of formulas that are being affected.

This one totals the hours worked for the week: The example shift would be deducted entirely from the total.
Code:
[/COLOR]=((F87-E87)*24)+((H87-G87)*24)+((J87-I87)*24)+((L87-K87)*24)+((N87-M87)*24)+((P87-O87)*24)+((R87-Q87)*24)[COLOR=#333333]

This one totals the amount of shifts between a certain time (based on values in another cell). The example shift, just gets completely ignored with this formula.
Code:
=(SUM(IF(E$87:E$111<$B87,IF(F$87:F$111>$A87,IF(F$87:F$111<$B87,F$87:F$111,$B87)-IF(E$87:E$111>$A87,E$87:E$111,$A87))))*24)

Any help would be awesome!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Without a date Excel doesn't know you went past midnight. One way around this is with the MOD function.
This link on time calculations may be of help. It will explain how this function works with time calculations.
https://www.youtube.com/watch?v=btiuexHSvHY

Format cell as General or Number.
Excel Workbook
ABC
16:00 PM1:00 AM7
Sheet
 
Upvote 0
Could the date be referenced on another cell? I have the date above each column.
 
Upvote 0
You're welcome. If you go to the main TouTube channel for Excel is Fun and type in the search box "hours worked" you will find a number of videos on this subject.

https://www.youtube.com/user/ExcelIsFun/search?query=hours+worked

Not sure how your data is set up, but maybe you could add the date & time as in the example below.
Column E is formatted as number.
Excel Workbook
ABCDE
110/30/201510/31/2015
26:00 PM1:00 AM7
Sheet
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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