Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,718
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

I now see that MOD does something unexpected (to me) with negative
numbers.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default FORMULA THAT CALCULATES HH:MM ON THIRD SHIFT(BETWEEN TWO DAYS)

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FORMULA THAT LIMITS WHAT IT CALCULATES VS WHATS ACTUAL Sandy Mann Excel Worksheet Functions 1 January 13th 07 05:41 PM
a formula which calculates empty cells jeff lebowski Excel Discussion (Misc queries) 1 July 15th 06 12:29 AM
need a formula which calculates points for a predictions league wallisi Excel Discussion (Misc queries) 1 May 26th 06 09:24 PM
formula that calculates upon saving only hw Excel Discussion (Misc queries) 2 May 26th 05 03:47 PM
How do I write an Excel formula that re-calculates every 24 hrs? heather Excel Discussion (Misc queries) 3 May 4th 05 10:58 AM


All times are GMT +1. The time now is 06:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"