Forum Discussion
CatherineMadden
May 26, 2023Brass Contributor
Time Calculation
How do I get the hours worked to not be negative numbers and to be correct? They are employees that work a 10 (3p-1a) or 12 hour (3p-3a) shift. Their shift starts "today" and ends "tomorrow". ...
Riny_van_Eekelen
May 26, 2023Platinum Contributor
CatherineMadden
May 26, 2023Brass Contributor
Never mind, I needed to change the time format, it worked perfectly. Thank you.
- CatherineMaddenMay 26, 2023Brass Contributor
Is there a way that I can get the OT Hrs to be a whole number? I was hoping that I could take the hours worked and subtract the normal shift to calculate over time hours but it gives the error message.
- SnowMan55May 26, 2023Bronze Contributor
Riny's formula is valid to get an elapsed time value (duration) into AO4, but it could produce negative numbers. Consider this instead:
=MAX( (I4-A4/24), 0 )
(In all these examples, the spaces are not required, but are included for readability.)
But if you need an actual whole number there, you need to decide how that should be calculated, as employees may work partial hours as well (I presume). E.g., what if Jane actually worked some minutes after 11:00 PM? Try one of these formulas:
To ignore fractions of an hour: =ROUNDDOWN( MAX( (I4-A4/24) * 24, 0 ), 0 ) To round up at half an hour: =ROUND( MAX( (I4-A4/24) * 24, 0 ), 0 ) If working any portion of an hour gets you wages for the full hour: =ROUNDUP( MAX( (I4-A4/24) * 24, 0 ), 0 )
Edit: I was in a hurry, and messed up the alternative to Riny's formula. It's fixed now.
- Riny_van_EekelenMay 26, 2023Platinum Contributor
CatherineMadden Presumably I4 contains 8 based on a time format. Thus the underlying number value is 8/24. That's how Excel stores times. If the 8 in A4 is the plain number 8, the formula will return a negative value that you can not display as time. Change the formula to
=I4-A4/24
That should work.