Why can't the datetime type value be changed to null? Solution
Source: Internet
Author: User
Why can't the datetime type value be changed to null? In my mysql table, there is a column pendingtime. The data type is datetime. the type selected when adding a column is timestamp. it can be blank. the default value is NULL. after adding a column, the default value is NULL. why can't I use SQL statements in php to modify the pendin datetime type value to null?
In my mysql table, there is a column pendingtime. The data type is datetime. the type selected when adding a column is timestamp. it can be blank. the default value is NULL. after adding a column, the default value is NULL.
In php, I used SQL statements to change pendingtime to now (). when pendingtime is meaningless, I changed it to NULL. I directly used SQL statements and could not change pendingtime to NULL, all prompts:
ERROR 1292 (22007): Incorrect datetime value: 'null' for column 'pendingtime '.
------ Solution --------------------
That cannot be done!
When mysql assigns values to datetime fields, there is a datetime format conversion process. if an invalid date format (such as null), an error is returned, you can use '000-00-00 00:00:00 'to leave it empty.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service