I have a table:
mysql> describe sk_users;
+------------------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------------+--------------+------+-----+---------+----------------+
| name | varchar(255) | NO | | NULL | |
| dst_date | datetime(6) | YES | | NULL | |
+------------------------------+--------------+------+-----+---------+----------------+
and data:
mysql> select name, dst_date from sk_users;
+------+----------------------------+
| name | dst_date |
+------+----------------------------+
| a | 2023-02-28 00:00:00.000000 |
| b | 2016-06-01 00:00:00.000000 |
| c | 0000-00-00 00:00:00.000000 |
+------+----------------------------+
I want to convert the 'dst_date' field from datetime to date, and when I'm trying to do it - I'm getting an error:
mysql> ALTER TABLE `sk_users` CHANGE `dst_date` `dst_date` DATE NULL;
ERROR 1292 (22007): Incorrect date value: '0000-00-00 00:00:00' for column 'dst_date' at row 3
I'm sorry, I can't figure out why I can't do this. Can you help me?
Thanks to juergen, I'm also tried to update the table to use NULL values instead, but it also gives me an error:
ERROR 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00' for column 'dst_date' at row 3