Query::date_range_clause PHP Method

date_range_clause() public method

# # Returns a SQL clause for a date or datetime field.
public date_range_clause ( $model, $field, $from, $to )
    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;
    }