Home > Database > Mysql Tutorial > Why Does MySQL Throw 'Incorrect Date Value: '0000-00-00'' After an Upgrade and How Can I Fix It?

Why Does MySQL Throw 'Incorrect Date Value: '0000-00-00'' After an Upgrade and How Can I Fix It?

Mary-Kate Olsen
Release: 2024-12-27 21:25:10
Original
798 people have browsed it

Why Does MySQL Throw

1292 - Incorrect Date Value: '0000-00-00' [Duplicate]

Explanation:

The error "Incorrect date value: '0000-00-00'" occurs when attempting to insert a date value of '0000-00-00' into a date column. This error has arisen after a recent MySQL upgrade.

Cause:

The issue is related to SQL mode, specifically strict mode. Strict mode has become more stringent with the advent of MySQL 5.7, disallowing the insertion of invalid date values such as '0000-00-00'.

Solution:

To resolve the error, strict mode can be disabled by executing the following query:

SET GLOBAL sql_mode = '';
Copy after login

This action deactivates strict mode and allows the insertion of the '0000-00-00' date value.

Additional Notes:

  • The query provided in the question attempts to insert various data into a table with a date column named 'fm_sctrdate'. This column is configured with a default value of '0000-00-00'.
  • It is crucial to use valid date values or cater for them with special cases in your application code to prevent future errors.

The above is the detailed content of Why Does MySQL Throw 'Incorrect Date Value: '0000-00-00'' After an Upgrade and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template