【发布时间】:2015-06-16 23:02:51
【问题描述】:
我想在mysql中检索两个日期之间的数据。
从日期:01/04/2015
迄今为止:01/05/2015
但我无法在单个变量中获取这些日期;
我是如何得到如下所述的:
$fdate=01;
$fmonth=04;
$tdate=01;
$tmonth=05;
$year=2015;
我在模型中的代码:
function date_range($fdate,$fmonth,$tdate,$tmonth,$year)
{
$this->db->select('*');
$this->db->where('DAY(order_date) >=',$fdate);
$this->db->where('MONTH(order_date) >=',$fmonth);
$this->db->where('YEAR(order_date) >=',$year);
$this->db->where('DAY(order_date) <=',$tdate);
$this->db->where('MONTH(order_date) <=',$tmonth);
$this->db->where('YEAR(order_date) <=',$year);
return $this->db->get('orders');
}
有时它会正确返回结果,有时它不会返回结果,但我在提到的两个日期之间在mysql 中有一个数据。
我在这段代码上犯了什么错误,请帮助我
【问题讨论】:
标签: php mysql codeigniter