View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default Calculate if 2 times differ by 24 hours?

Errata....

On Dec 28, 2:33*pm, joeu2004 wrote:
=IF(B1+B2-A1-A21,"24 hr","<=24 hr")
=IF(ROUND((B1+B2-A1-A2)*86400,0)86400,"24 hr","<=24 hr")

[....]
__Both__ formulas should do that. *I was recommending the second
formula to avoid anomalies ("errors") that arise a result of computer
binary arithmetic.

Although you might [not] uncover any such anomalies in your testing,
they might arise eventually. *They are a common problem.


On second thought, the second formula (with ROUND) should not be
necessary __if__ the times in A1 and B1 are __constants__, not
computed by formulas, which seems to be true in your case.

I have helped so many people whose formulas behave unexpectedly due to
infinitesimal anomalies arising from computer binary arithmetic that,
arguably, I have become unduly sensitive to the problem, and I over-
reacted.

Just to be sure, I did run through all 86400 seconds in a day,
comparing with 24hr + 1sec, and I confirmed that the two formulas
always agree.

That should not be surprising considering how large 1 second,
represented as a fraction of a day, is compared to the precision of
time with a current date. But when date/time is computed, computer
arithmetic anomalies can still arise, I believe, in part because the
precision of time with a current date is less than the precision of
time alone.

If that's too confusing, simply disregard it. I am merely trying to
justify my concern, which seems misplaced when time is a
__constant__.

Much ado about nothing.