PDA

View Full Version : How do you stop this time calculation formula from rounding


chris1962
Feb 2, 2009, 04:00 PM
I did not make this formula, but found it on the internet. I am trying to figure out how to make it stop rounding. It is the "total" cell for the "time in" and "time out" on a timesheet. The cell is formatted as "time". I want it to return exact minutes worked and not round. Can someone please help?

=IF((OR(K8="",K7="")),0,IF((K8

chris1962
Feb 2, 2009, 04:02 PM
Sorry, prior questions did not post all of the formula.

Chris

=IF((OR(K8="",K7="")),0,IF((K8<K7),((K8-K7)*24)+24,(K8-K7)*24))

LinfieldPA
Feb 2, 2009, 04:43 PM
I guess you're trying to calculate wages from someone's TIME IN and TIME OUT? If so, see if the attached makes sense to you. It will calculate number of minutes and calculate wages with a per minute rate. I can expand/explain further if it doesn't fit into your scenario. (Not sure what the "24"'s were for in the formula you found.)

Let me know if it's what you're looking for...

Brian

ScottGem
Feb 2, 2009, 04:45 PM
If you format a cell as time format then it should display in hh:mm format.

JBeaucaire
Feb 2, 2009, 06:08 PM
Properly formatted as time as Scott suggests gives you the ability to directly add and subtract the cells. Format ALL the requisite cells as hh:mm including the cell that is getting this formula, then you can simply add/subtract:

=IF(OR(K8="",K7=""),0,IF(K8<K7,K7-K8,K8-K7))

JBeaucaire
Feb 2, 2009, 06:30 PM
Although, now that I look at what your formula is doing, you do need to take into account the midnight issue. I've fixed that too in the RED section.

=IF(OR(K8="",K7=""),0,K8-K7+(K7>K8))

This simple formula assumes all times are represented in 24hr format.

4:00 - 10:00 = 18hrs with that formula since 4:00 is 4am.
16:00 - 10:00 = 6hrs as 16 is 4pm
22:30 - 8:00 = 8:30

The underlined trick at the end is a simple true/false and will add 24 if true without needing another IF statement.

chris1962
Feb 11, 2009, 12:32 PM
I just wanted to thank all you guys for the help. Both formulas worked. I usually only do simple formulas in Excel and never time formulas, you have saved me a lot of time and frustration!

JBeaucaire
Feb 11, 2009, 04:05 PM
Always glad to help. Keep us on speed dial.