Thursday, 12 September 2013

php/Codeigniter-- How to compare only date by excluding time

php/Codeigniter-- How to compare only date by excluding time

i have a field in my db table as creater_date as datetime and having
values stored in the form of 2013-09-13 02:12:44
Now i have to compare today-date(no time) with creater_date table field .
I tried this below code but it is showing error :
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;
}
}
Getting error :
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

No comments:

Post a Comment