SQL Query Question: How to count items between two dates

Hi all,

Bit confused on creating a criteria to calculate the items between two dates.

Any help?

Is it a bug?

down vote favorite

I have a table with column date_reservation

When I use simple SQL query function to get the total items between two dates using HAVING, it results correctly but when I use model of that table and set the criteria using CDBCriteria it says that column date_reservation defined in having clue does not exist.

Here is my SQL Query

SELECT * FROM booking WHERE id_domain=‘1’ AND lang=‘fr’ HAVING date_reservation >‘2011-06-06 00:00:00’ AND date_reservation< ‘2011-06-10 00:00:00’

and Here is Query Generated by CDBCriteria

Error in querying SQL: SELECT COUNT(*) FROM booking t WHERE id_domain=‘1’ AND lang=‘fr’ AND ref_booking LIKE ‘%’ HAVING date_reservation >‘2011-06-08 00:00:00’ AND date_reservation <‘2011-06-10 00:00:00’