Filtering i18n date in Admin CGridView

Hey, guys!!

I have to filter CGridView using a date field. The problem is that i have to inform the date in i18n format, like d/m/Y, so i’ve made some changes in the model search function to transform the parameter into a database format:


		if($this->offerDateStart <> ''):

			$datetransf = date('Y-m-d', CDateTimeParser::parse($this->offerDateStart, Yii::app()->locale->dateFormat));

			$criteria->compare('offerDateStart', $datetransf ,false, '>=');


			$datetransf = null;


Neither $criteria->compare nor $criteria->addSearchCondition gives me the corresponding ">=" SQL operator, I only get the following SQL:

....WHERE (offerDateStart=:ycp0). Bind with parameter :ycp0='2010-08-03'

One could say that I shoud use the operators in the grid, but if I try to convert the string “>=22/03/2010” into a valid sql date, I’ll get 1969-12-31 (null value)

…unless somebody tells me that there is a way to get the pure value entered in the grid, without the operator

Any help will be very appreciated!!




Haven’t tested, but it should work

$criteria->compare('offerDateStart', '>='.$datetransf ,false);