$this->db->select('*');
$this->db->from('Table_name');
$this->db->where('STR_TO_DATE(_date, "%Y-%m-%d") BETWEEN STR_TO_DATE("$start", "%Y-%m-%d") and STR_TO_DATE("$ends", "%Y-%m-%d")');
这是我的查询,但它不起作用。我在CodeIgniter框架中工作
答案 0 :(得分:0)
您可以使用 datepicker 来获取输入。这对你来说会更容易。 https://jqueryui.com/datepicker/
这对你有用。 _date 是列名
$this->db->where('_date >=', STR_TO_DATE($start, '%Y-%m-%d'));
$this->db->where('_date <=', STR_TO_DATE($ends, '%Y-%m-%d'));
print_r($this->db->get('Table_name'));
答案 1 :(得分:0)
$end_date = date('Y-m-d', strtotime('now'));
$start_date = date('Y-m-d', strtotime('2018-01-01')); //enter date according to your requirements
$query = $this->db->query("SELECT * FROM table-name WHERE date BETWEEN '$end_date' AND '$start_date'");
return $query_result();
答案 2 :(得分:0)
这项工作形成了我。
$start_date = date('Y-m-d', strtotime($start));
$end_date = date('Y-m-d', strtotime($ends));
$this->db->where('_date >=', $start_date);
$this->db->where('_date <=', $end_date);
$query = $this->db->get('table_name');