Filter By Date Range in CGridView

Hi,

I have a created_on field in my CGridView. Currently I can use the default filter right below the header to type in a specific date, hit return, and get results for that date only.

But how can I do the same thing for a date range – ie, enter both a start and end date?

Thanks.




 in your model's search method add something like


// find dates in between for the created date

if(strlen($this->topic_date) && strlen($this->topic_date_end)) {

			$criteria->params[':topic_date'] = date('Y-m-d', strtotime($this->topic_date));

			$criteria->params[':topic_date_end'] = (strlen($this->topic_date_end)) ? date('Y-m-d', strtotime($this->topic_date_end)) : $criteria->params[':post_date'];

			$criteria->addCondition('DATE(topic_date) BETWEEN :topic_date AND :topic_date_end');

		}




pcs,

thanks for the reply. how do i create the filters in the actual view though? that is, the default filter that is below the created_on header is only a single text input – so i cannot put both a start and end date.

yeah i don’t think you can, i actually do this in the advance search form

i havn’t used that before, can you link me to something on this advanced search form?

thanks.

Thank you very much,I wanted to do a date range search in advanced search ,but was’nt quite sure.

You saved me big time!