I don't get it, do you want to check how many rooms are available in a given timeslot (periode)?
how about booking the rooms from startdate till enddate.
then you can select following:
count(room) where not ($startdate < enddate AND $startdate > startdate) AND not ($enddate > startdate AND $enddate < enddate) AND not ($startdate > startdate AND $enddate < enddate)
$startdate < enddate AND $startdate > startdate
gives you all rooms where $startdate lies between its booking-dates
$enddate > startdate AND $enddate < enddate
gives you all rooms where $enddate lies between its booking-dates
$startdate > startdate AND $enddate < enddate
gives you all rooms where $startdate and $enddate lies between its booking-dates
So if you don't select those you will get any room that is free in the given periode.
This gives you the opportunity to book a room the same day the previous booking ends - so remember to tell your guests that they shouldn't check-in until 3pm 😉