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?
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');
}
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.