1292 – Incorrect date value: ‘0000-00-00’ for column ‘date’

MySQL Error 1292 – Incorrect date value: ‘0000-00-00’

You run into 1292 – Incorrect date value: ‘0000-00-00’ for column ‘date’ error because since version 5.7, MySQL enables SQL Strict Mode by default and does not permit ‘0000-00-00’ as a valid date value.

For more information check MySQL Documentation 5.7

Before we start


Apache Web Server

  – Have you installed apache? Check out our article Install Apache on CentOS 7.

PHP

– Have you installed PHP? Check out our article Install PHP on CentOS.

MySQL

– Have you installed MySQL? Check out our article Install MySQL on CentOS 7.

Please follow the below step to fix this.

Solution 1

If you are using phpMyAdmin

1) Click on the variables menu in PHPMyAdmin
2) Find the sql_mode variable and edit this line.
3) Remove NO_ZERO_DATE from sql_mode
4) Save it.

Please check the below screenshot for a better understating.

SQL Mode in PHPMyAdmin
SQL Mode in PHPMyAdmin

Solution 2

  1. You can check the SQL mode from the MySQL using below query
  2. SELECT @@GLOBAL.sql_mode global, @@SESSION.sql_mode SESSION
  3. So you can disable it by removing it from the MySQL configuration file, or run the below query.
  4. SET GLOBAL sql_mode = '';
  5. Then restart the MySQL server and you should be able to use ‘0000-00-00’ as a value for the DATE column.

I hope it helped you to fix error 1292 – Incorrect date value: ‘0000-00-00’ for column ‘date’. Please let us know in the comment section if you have any concerns.

Thank You!