Solved

Problem with DATETIME column in MySQL

Posted on 2016-07-30
4
33 Views
Last Modified: 2016-08-04
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?
0
Comment
Question by:William Nettmann
  • 3
4 Comments
 
LVL 6

Expert Comment

by:Manuel Marienne-Duchêne
ID: 41735751
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
0
 
LVL 12

Author Comment

by:William Nettmann
ID: 41735756
Thanks, Manumd - that is obviously why I have a problem.

Now, I need to find a way to fix it.
0
 
LVL 12

Accepted Solution

by:
William Nettmann earned 0 total points
ID: 41735773
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.
0
 
LVL 12

Author Closing Comment

by:William Nettmann
ID: 41742159
I found my own answer.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now