Reputation: 145
I am trying to update a MySQL table with current date into a column which type is DATE. current date structure is (2014-05-15). I've tried a few ways but it is not updating the date, however it is updating other fields.
MySQL query.
$q = "UPDATE TABLE SET
DESCRIPTION =".$db->qstr($string).",
DATE =".$db->qstr(date('Y-m-d')).",
LAST_ACT =".$db->qstr( time())."
WHERE ID=".$db->qstr( $id);
I've tried DATE = DATE(NOW()), and DATE = DATE(), but it is not updating in MySQL,
Any suggestions?
Upvotes: 0
Views: 3201
Reputation: 31
It is very simple. Use now() function for it.
So it will be :
DATE = now()
Upvotes: 0
Reputation: 164
Try DATE=CURDATE() which will return a date data type. If that doesn't work, try doing some trial and error directly in the database console to see what works and what responses you get. And be sure and update us on the results.
Upvotes: 0