Problem with DATETIME column in MySQL

William Nettmann
William Nettmann used Ask the Experts™
on
I have a table with a column defined as follows:
`Listing_Date` datetime DEFAULT NULL,

Open in new window

Running the following queries return results normally:
select count(*) from caselaw.cases;
select count(*) from caselaw.cases where Listing_Date = '0000-00-00 00:00:00';

Open in new window

However,
update caselaw.cases set Listing_Date = null where Listing_Date = '0000-00-00 00:00:00';

Open in new window

returns the following error:
Error Code: 1292. Incorrect datetime value: '0000-00-00 00:00:00' for column 'Listing_Date' at row 1
How can I get rid of the '0000-00-00 00:00:00' values?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
In myssql doc the limit date is

'1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

http://dev.mysql.com/doc/refman/5.7/en/datetime.html
William NettmannPHP Web Developer

Author

Commented:
Thanks, Manumd - that is obviously why I have a problem.

Now, I need to find a way to fix it.
PHP Web Developer
Commented:
Found a workaround:

Add
[mysqld]
sql_mode = 

Open in new window

tp the MySQL configuration file, which disables "strict mode", and the update can be done.
William NettmannPHP Web Developer

Author

Commented:
I found my own answer.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial