我有一个查询如下:
$query = $this->db->get_where('Bookings', array('Status' => 0, 'Driver_ID' => null, 'Date'=> 'NOW()'));
Date 字段是日期时间类型,我想记录日期与今天相同的记录,但是上面的内容以及我厌倦的其他所有内容都不起作用。
任何人都可以告诉我如何正确提取日期为今天的记录,忽略日期时间的时间部分。
感谢您的帮助
更新
我现在已将查询转换为以下内容
$start = date('Y-m-d 00:00:00');
$end = date('Y-m-d 23:59:59');
$query = $this->db->get_where('Bookings', array('Status' => 0, 'Driver_ID' => null, 'Date' => 'BETWEEN '.$start.' AND '.$end));
然而还是没有运气,只是重新调整没有结果!
最佳答案
我会努力
$this->db->where('Status', 0);
$this->db->where('Driver_ID', null);
$this->db->where('DATE(Date)', date('Y-m-d'), FALSE);
$query = $this->db->get('Bookings');
关于mysql - Codeigniter 和 MYSQL 日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10192292/