Home >Database >Mysql Tutorial >How to Fix MySQL Error #1292: 'Incorrect date value: '0000-00-00''?
When attempting to insert a date value of '0000-00-00' into a column with a MySQL date type, the following error occurs:
#1292 - Incorrect date value: '0000-00-00'
This error is likely caused by strict mode being enabled in the MySQL database. In MySQL 5.7 and later versions, strict mode is enabled by default and enforces stricter validation rules for data integrity. One of these rules is that date values cannot be '0000-00-00'.
To resolve this issue, disable strict mode using the following query:
SET GLOBAL sql_mode = '';
This query removes all strict mode settings, including the validation rule that prevents '0000-00-00' from being inserted as a date value.
MySQL's strict mode provides additional data integrity checks, but it can also make it more difficult to work with certain types of data. If you do not require strict validation, it is recommended to disable strict mode to prevent this error from occurring.
For more information on strict mode in MySQL, refer to the official MySQL documentation.
The above is the detailed content of How to Fix MySQL Error #1292: 'Incorrect date value: '0000-00-00''?. For more information, please follow other related articles on the PHP Chinese website!