Hi Dennis
I'm not sure my explanation will be exactly accurate, but here goes.
Time is stored as fractions of a day, thus
08:00 = 0.33333333
09:00 = 0.375
02:00 = 0.08333333
If one includes a date as well as time, then 08:00 26 Sep 2006 would be
stored internally as 38987.33333333
If no date is included, and one tries to subtract an "apparently"
earlier from an "apparently" later time, then the result is negative and
is not permitted in Excel under the 1900 date system. If, however, the
"apparently" earlier time belongs to the next 24 hour period, then
adding 1 would be equivalent to adding 1 to the date.
In the example above, 02:00 - 09:00 = 0.08333333 - 0.375 = - 0.29166667
Since negative time is not allowed, add 1 to the result gives = 1 -
0.29166667 = 0.70833333
0.708333333 as a fraction of 24 hours = 17:00 hours
Using MOD() to achieve the same thing works as follows
=MOD(02:00-09:00,1) = MOD(0.08333333 - 0.375 ,1 ) =MOD(- 0.29166667,1)
= 17
The MOD function can also be expressed as
MOD(n, d) = n - d*INT(n/d)
with n = 02:00 - 09:00 = 0.08333333 - 0.375 = - 0.29166667
and d = 1
INT(n/d)= -1
d*INT(n/d) = -1
- 0.29166667 -1 = 0.708333333 = 17
--
Regards
Roger Govier
dk_ said:
David Biddulph said:
Yes, it does work, Dennis. If it's not working for you, then look
again at
the numbers in D8 & E8 and in the answer cell (formatting each of
them as
number, if need be), & tell us what values are there.
If, of course, you've got shifts that last longer than 24 hours, that
method
(and the other simplified suggestions) won't work and you'd need to
put
proper date & time in D8 & E8 & just use E8-D8 formatted as [h]:mm
for the
answer.
David,
My bad. You're right, =MOD(E8-D8,1) does work. I typed my formula
wrong
for testing.
However, not only do I now NOT know why =MOD(E8-D8,1) works, I still
don't understand why adding a "1" using (E8<D8) works. Adding "1" does
add 24 hours to my hour counting., it just makes the hours add in
order
as time goes by.
Thanks.
-Dennis