function date_range_clause($model, $field, $from, $to)
{
$cond = array();
if (strlen($from)) {
$cond[] = array($model . '.' . $field . ' >' => date('Y-m-d 23:59:59', strtotime($from . ' day')));
}
if (strlen($to)) {
$cond[] = array($model . '.' . $field . ' <=' => date('Y-m-d 23:59:59', strtotime($to . ' day')));
}
return $cond;
}