CGridView date filter format

Hello, I have a CGridView with a date column. I don’t want to search for a date range or anything crazy like that, just the date. I have the datepicker jquery calendar all set up, and so when I click a date it appears in the filter field like so: 01/08/2012.

Since the fields in the date column appear as MySQL format (2012-01-08), it doesn’t match up, so I tried the following in the model’s search function:

if(strlen($this->date)) {

        $criteria->params[':date'] = formatDate($this->date);



My formatDate function transforms the date into MySQL format and it absolutely works correctly, but unfortunately, this doesn’t work and it produces 0 results. When I input the date manually in the search function, like so:

$criteria->params[':date'] = "2012-01-18";


it still doesn’t even work.

What modifications to this would I have to make to get this to work? Thanks.

How about using MySQL date format function?


Still nothing…I’ve tried all of the following:

$criteria->compare('date',"DATE_FORMAT(" . $this->date . ",'%Y-%m-%d')");

$criteria->compare('date',"DATE_FORMAT(" . $this->date . ",'%m/%d/%Y')");



I try every combination and still nothing…so frustrating :( I just wish there were examples of this…all I can find are date ranges.

Nvm…figured it out. Didn’t realize I had to remove the default statement “$criteria->compare(‘date’,$this->date,true);” for the new statement to work.