Facing Problem With $Criteria->Compare While Performing A Search


I am facing a problem with $criteria->compare while comparing an input date to the database date.

$criteria = new CDbCriteria();

$criteria->compare(“enquiry_date =’”.date(‘Y-m-d’, strtotime($_REQUEST[‘tDate’]))."’");

$modelEnq = TblEnquiry::model()->findAll($criteria);

This resulting empty array. I have declared enquiry_date as datetime field, and the input box is a datepicker that only inputting date not datetime to compare.

Please help.



First of all, compare() takes two arguments


so your code should look something like this

$criteria->compare('enquiry_date', date('Y-m-d', strtotime($_REQUEST['tDate']));

Thanks Orey,

          I used '$criteria->condition' instead of compare and it works for me.