Not exhaustively tested, but try this
=MAX(MIN(B1,$N$1)-MAX(A1,$M$1),0)
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Micos3" <[email protected]> wrote in message
news:[email protected]...
> What i want to do is dificult to explain so i'll try making a scheme.
>
> A B C D M N
> 1 9:30 12:00 Ponta 2:30 8:00 16:00
> 2 21:00 0:00 Cheias 0:00
> 3 07:00 09:30 Cheias 1:30
> 4 0:00 07:00 Vazias 0:00
>
> I table ABC i count many periods of the day in wich i call in cell C the
> name i want to other mission, in cell D i count the hours that period M:N
> shows that are in period A:B.
> I've made this formula but isn't working well, and also i'm having trouble
> in counting 0:00 (24:00), example of line 1.
>
>
=IF($A1>N1;0;IF(AND($A1>$M1;$N$1>=$B1);B1-A1;IF(AND($A1>$M1;$N$1=<$B1;$A1>$M
1);N1-A1;IF(AND($A1<$M1;$N$1>=$B1;B1>M1);B1-M1;IF(B1<M1);0))))
>
> Understand what i a'm trying to do?
> tks
Bookmarks