• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to determine if a hour is inside a range of time

Hélio

New Member
Hello, I would like to know how to determine if a time falls between a time range. I have a table with a group of events and need to put 1 everu time the time range falls inside a period..

Please see my table..
 

Attachments

I'm guessing A is Start? And also assuming it's not inclusive if end time falls exactly at 5:00 PM.

In E2:
=IF(AND(HOUR($A2)<=HOUR(E$1),MEDIAN($A2,$B2,E$1)=$A2),1,IF(AND($B2>E$1,MEDIAN($A2,$B2,E$1)=E$1),1,0))

Copy down and across.
 

Attachments

Ah ha! Forgot that hour is represented by 1/24.

To exclude where End time falls right on the hour.
=N(IF($B2=E$1,0,MEDIAN(INT($A2*24)/24,INT($B2*24)/24,E$1)=E$1))
 
Shorting a little the formulae:

=N(INT(24*MEDIAN($A2,$B2,E$1)+10^-4)/24=E$1)
=N(HOUR(MEDIAN($A2,$B2,E$1))=HOUR(E$1))


And with the idea of @Chihiro:

=($B2<>E$1)*(INT(24*MEDIAN($A2,$B2,E$1)+10^-4)/24=E$1)
=($B2<>E$1)*(HOUR(MEDIAN($A2,$B2,E$1))=HOUR(E$1))

Blessings!
 
Last edited:
Hello team, all solutions fit for the question, I have tested all... many thanks..

You all are really masters on that!!!

God bless you all...
 
Back
Top