2017-03-29 17 views

回答

0

使用DATE(addeddate)在where子句

對於入住日期條件使用DATE()對於DATETIME類型列

嘗試下面的腳本

$this->db->select("*"); 
$this->db->from("sales_commission"); 
$this->db->where('DATE(addeddate) >=','2017-03-02'); 
$this->db->where('DATE(addeddate) <=','2017-03-28'); 
$query = $this->db->get(); 
if($query->num_rows() > 0){ 
echo "<pre>"; 
print_r($query->result()); 
}else{ 
echo "No records found!"; 
} 
0

無需通過爲array。使用如下所示的$this->db->where()result_array()用於以array格式打印數據。

$this->db->where('addeddate >=','2017-03-02'); 
$this->db->where('addeddate <=','2017-03-28'); 
$this->db->select("*"); 
$data = $this->db->get("sales_commission"); 
print_r($data->result_array());//prints records between matched dates 
相關問題