View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_814_] Rick Rothstein \(MVP - VB\)[_814_] is offline
external usenet poster
 
Posts: 1
Default Wrong count of time

I am pretty sure this formula will do what you want...

=IF(E3=0,0,(MIN(24*F3+2,7)-MOD(MAX(24*E3,22)+2,12))/24)

where I just repeated your condition that if E3 equals 0, the result should
be 0.

Rick


"H. Nissen" wrote in message
...
Hello

I simply can not understand that the following code does not work when
"the
time" is equal to or less than 24:00

= IF (E3 = 0; 0; IF (AND (E3 <F3; MEDIAN (E3; F3; 0) = E3); MOD (MIN (TIME
(5, 0, 0); F3)-E3; 3); V (MIN (TIME (5, 0, 0); F3)-MAX (E3; TIME (22, 0,
0));
1)))

The formula must count the hours between 22:00 and 5:00 in a random time,
for example. 16:00 to 2:00 = 4 hours.

But if the term is before 24:00 counts it wrong.

T.ex. 16:00 to 24:00 it counts 7 hours. It should be 2 hours.

I hope some of you sharp minds to help me to solve this problem:)

Best regards

H. Nissen