Cgridview With Only Records From This Month?


I have a payment model with a payment_time field (it is mysql datetime). My question is in CGridView, how do I list only payment made in current month by default? Of course, user still can use "Advanced Search" in _search.php to find all other records. Please shred some light! Thank you!

This data provided for the CGridView should do the trick.

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

        'criteria' => array(

            'condition' => 'payment_time >= "' . date('Y-m-01 00:00:00') . '"',




Why don’t you try this extension, remember-filter-gridview I found it useful, and you can set default value to this month, but still able to see others easily.

Thank you Bizley and Daniel, I will experiment with both and let you know the outcome :)