CActiveDataProvider filter data by date range

trying to filter a table by date with the following code in the controller, but it shows "No result found" even though I got valid data that should fit the bill. What am I doing wrong?





$dataProvider=new CActiveDataProvider('Event', array(

                    'criteria'=>array(

                        'condition'=>'date >= '.date('Y-m-d', strtotime('-2 years')),

                    ),

                ));




What SQL is being generated?

Is ‘date’ a column in your table?

What is the result of this expression:


date('Y-m-d', strtotime('-2 years')

Sorry, but how do I look at what SQL is being generated?

Yes, ‘date’ is a column in my table.

if I echo


date('Y-m-d', strtotime('-2 years')

in a view, I get something like ‘[color=#555555][font=Arial, Helvetica, sans-serif][size=2]2009-12-21[/size][/font][/color]’

I solved it…

quotation problem…


'condition'=>'date >= "'.date('Y-m-d', strtotime('-2 years')).'"',

Moved to Yii 1.1.x.