Why can't the datetime type value be changed to null? Solution-php Tutorial

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. in php, I used an SQL statement to change pendingtime to now (). when pendingtime is meaningless, I changed it to NULL. Why can't I change the 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.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.