我需要在兩個日期之間獲取數據,但它不工作。比較月份和年份Mysql
我的表 -
從日期和日期參數 -
$from_date = '2016-12';
$to_date = '2017-03';
表列月類型是VARCHAR
$this->db->select('*', FAlSE);
$this->db->where('t.Flag', '0');
$this->db->where('tpd.Status', $status);
$this->db->where("STR_TO_DATE(tpd.Month, '%Y-%m') >=", date($from_date));
$this->db->where("STR_TO_DATE(tpd.Month, '%Y-%m') <=", date($to_date));
$this->db->from('test_periodicity_details tpd');
$this->db->join('test t', 'tpd.Test_Id=t.Test_Id');
$this->db->join('school_information si', 't.School_Id=si.School_Id', 'left');
$this->db->join('test_status ss', 'tpd.Status=ss.Test_Status_Id', 'left');
echo $this->db->get_compiled_select();
$query = $this->db->get();
if ($query->num_rows() > 0){
return $query->result();
}
else {
return false;
}