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.