Page 1 of 1

count frequancy between dates!

Posted: Fri Jan 28, 2005 10:22 am
by jenny kaur
i want to know how i would show the number of booked rooms each day over a given period.

$datein="2005-02-05";
$dateout="2005-02-09";

i tried array_count_values but didnt work.

MY Database table:

+----+--------------+---------------+
+ id.+ ..bookdate + enddate +
+----+--------------+---------------+
+ 1. + 2005-02-05 + 2005-02-06 +
+----+--------------+---------------+
+ 2. + 2005-02-05 + 2005-02-07 +
+----+--------------+---------------+
+ 3. + 2005-02-05 + 2005-02-08 +
+----+--------------+---------------+

Code: Select all

$query = "select * FROM rooms WHERE bookdate < '$dateout' AND enddate > '$datein'";
the output i woud like would be like below:

-- 2005-02-05 -- 2005-02-06 -- 2005-02-07 -- 2005-02-08
_______3___________2___________1___________0____

please help!

Posted: Fri Jan 28, 2005 10:24 am
by John Cartwright
possibly try

Code: Select all

$query = "select count(*) FROM rooms WHERE bookdate < '$dateout' AND enddate > '$datein'";

Posted: Fri Jan 28, 2005 10:28 am
by jenny kaur
hi thanks for reply, but that will count all the booked rooms for the whole period...i want to know how many booked rooms per day in that period.

i.e:

-- 2005-02-05 -- 2005-02-06 -- 2005-02-07 -- 2005-02-08
___3 booked____2 Booked_____1 Booked____0 booked__

Posted: Fri Jan 28, 2005 10:39 am
by feyd
because the individual days are not stored, you may need to compute that yourself.

Posted: Fri Jan 28, 2005 10:53 am
by jenny kaur
Hi Feyd,

yes i know i have to compute that myself, but how is what i am asking???