mysql: ERROR 1292 (22007): Incorrect date value: '0000-00-00'
Code:
mysql> UPDATE some_table SET some_date_column='2024-04-10' WHERE some_date_column='0000-00-00' ; What is please optimal solution ? |
without details hard to say anything. What is that database, what is that some_table and what is that some_date_column? Anyway, 0000-00-00 is not a valid date. It also may depend on the configuration of the database/table/whatever.
So how do you think we could tell what the optimal solution would be? Probably: some_date_column='1732-11-23' |
Code:
UPDATE some_table SET some_date_column='2024-04-10' Code:
UPDATE some_table SET some_date_column='2024-04-10' |
Hi
It has to do with sql mode: https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html The default has changed in newer versions. After 8.0, the default setting for allow invalid dates changed: https://dev.mysql.com/doc/refman/8.3...sql-modes.html The setting you need to change is probably NO_ZERO_DATE. |
... but you should also fix that database! Maybe you temporarily set the configuration to allow "0000-00-00" to be referenced, having determined that the value is actually there. Then, one time, execute a query to UPDATE those values to NULL as they should be. Then, promptly set the configuration back.
(Of course, you will also need to first review the source-code of any applications which now reference that database, so that your change does not break them.) |
Quote:
|
There are some valid points here. Although, in a production environment you would never have the need to update a null datetime. Instead do some debugging and find out why it inserted with date 0000-00-00 in the first place.
|
Quote:
Sending useless information is not a problem, but hiding relevant information can make it intractable. Remember, we don't see your host, we don't know your thoughts. http://catb.org/~esr/faqs/smart-ques...html#beprecise |
Isn't this already solved by Guttorm's post #4?
|
Quote:
|
Quote:
|
Quote:
Do you think Code:
some_date_column='1732-11-23' |
Quote:
|
Quote:
|
All times are GMT -5. The time now is 12:11 PM. |