我的数据库表中有一个字段creater_date
作为日期时间,并且值以以下形式存储2013-09-13 02:12:44
现在我必须将 today-date(no time) 与 creater_date
table field 进行比较。
我尝试了下面的代码,但它显示错误:
function check_existing_User_weightStatus($u_id)
{
$this->load->database();
$this->load->helper('date');
$today = date('Y-m-d');
$array = array('creater_id' => $u_id,DATE('created_date') => $today);
$this->db->where($array);
$query = $this->db->get('user_weight');
if ($query->num_rows() > 0) {
return true;
} else {
return false;
}
}
得到错误:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '13 Sep 2013 02:48:27 +0530Asia/Calcuttaam30Asia/Calcutta13_13am30Asia/Calcutta '' at line 4
SELECT * FROM (`user_weight`) WHERE `creater_id` = '3235' AND `2013-09-13T02:48:27+05:30Fri,` 13 Sep 2013 02:48:27 +0530Asia/Calcuttaam30Asia/Calcutta13_13am30Asia/Calcutta '2013-09-13'
Filename: D:\xampp\htdocs\webapp\system\database\DB_driver.php
Line Number: 330
我不想和时间比较,我只想和今天的日期比较。该字段created_date
(例如 2013-09-13 02:12:44)具有datetime
具有一些时间值的数据类型。但我只想与日期进行比较