Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
i am trying to find a formula that calculates time difference in hh:mm when
the shift runs between 22:00 and 07:00 |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Assuming
A1= 22:00 B1= 07:00 =B1-A1+(A1B1) Format as hh:mm "Norman" wrote: i am trying to find a formula that calculates time difference in hh:mm when the shift runs between 22:00 and 07:00 |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
One way:
A1: 22:00 A2: 07:00 A3: =MOD(A2-A1,1) Format A3 as elapsed time: [h]:mm In article , Norman wrote: i am trying to find a formula that calculates time difference in hh:mm when the shift runs between 22:00 and 07:00 |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
A1: 22:00
A2: 07:00 A3: =MOD(A2-A1,1) I don't understand why this works. Isn't the remainder of -.625/1 still -.625 ? Since the result of MOD takes the same sign of the divisor shouldn't A3 resolve to .625 (15:00)? time passes.... Before I sent this, I looked again at help: MOD(n, d) = n - d*INT(n/d) I do understand why n - d*INT(n/d) works, but then the definition of MOD ("Returns the remainder after number is divided by divisor. The result has the same sign as divisor") doesn't seem accurate. |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I now see that MOD does something unexpected (to me) with negative
numbers. |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I suspect your confusion stems from INT()'s rounding *down* to the next
lowest integer, rather than toward zero. In article , Andy wrote: I now see that MOD does something unexpected (to me) with negative numbers. |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Well,
-0.625 - 1 * INT(-0.625/1) is equivalent to -0.625 - 1 * (-1) is equivalent to 0.375, or 08:00. In article , Andy wrote: A1: 22:00 A2: 07:00 A3: =MOD(A2-A1,1) I don't understand why this works. Isn't the remainder of -.625/1 still -.625 ? Since the result of MOD takes the same sign of the divisor shouldn't A3 resolve to .625 (15:00)? time passes.... Before I sent this, I looked again at help: MOD(n, d) = n - d*INT(n/d) I do understand why n - d*INT(n/d) works, but then the definition of MOD ("Returns the remainder after number is divided by divisor. The result has the same sign as divisor") doesn't seem accurate. |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I get that Int rounds down for negative numbers, and I understand why
-0.625 - 1 * INT(-0.625/1) = .375 So if Mod is defined as <<MOD(n, d) = n - d*INT(n/d), I get it. (And it's damn handy for figuring the difference between two times spanning midnight.) But if Mod is defined as "Returns the remainder after number is divided by divisor. The result has the same sign as divisor", then I don't get it. If 11 is divided by 3, the remainder is 2. What is the remainder of -11 divided by 3 ? What is the remainder of 11 divided by -3 ? -11/3 = 11/-3 = -(11/3) !!! Ok, I can see when I do the long division with either the divisor or the dividend being negative I am either subtracting 9 from -11 (=-20) or subtracting -9 from 11 (=20), which is different from the remainder when both divisor and dividend are positive, 2 (or both negative, -2). I guess I never knew what the "remainder" was when the divisor and dividend were different signs. It somehow ends up being what the remainder would have been if all was positive, added to the divisor, the divisor keeping its sign, and the remainder keeping the sign of the dividend. Let's see... Oh, that would be n - d*INT(n/d). Ok, I'm done ;) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
FORMULA THAT LIMITS WHAT IT CALCULATES VS WHATS ACTUAL | Excel Worksheet Functions | |||
a formula which calculates empty cells | Excel Discussion (Misc queries) | |||
need a formula which calculates points for a predictions league | Excel Discussion (Misc queries) | |||
formula that calculates upon saving only | Excel Discussion (Misc queries) | |||
How do I write an Excel formula that re-calculates every 24 hrs? | Excel Discussion (Misc queries) |