Data Comparision In Cdbcriteria

HI All,

Just a little confused with the statement below which I am using for search




if(!empty($this->to_date) && !empty($this->from_date))

        {

            $criteria->condition = "t.created_date  >= '$this->from_date' and t.created_date <= '$this->to_date'";

        }else if(!empty($this->from_date) && empty($this->to_date))

        {

            $criteria->condition = "t.created_date >= '$this->from_date'";

        }else if(!empty($this->to_date) && empty($this->from_date))

        {

            $criteria->condition = "t.created_date <= '$this->to_date'";

        }	



Should this also return result for today’s date if any entries are present in the database. But it is equivalent to using < and > ( not =< and >= ). Because I need to select 2014-02-11 even in order to display search result for 2014-02-10. Not quiet sure. Let me know if you can help.

Thanks.

Does your date columns are of date or timestamp type? Consider this example:




2014-02-10 11:22:00 <= 2014-02-10 is false

2014-02-10 00:00:00 <= 2014-02-10 is true



You probably should cast your db columns to dates.

I think tats the point. I should probably convert the timestamp type to date and use comparision. Thanks a lot.