Update invalid dates with NULL

When a date has an invalid date '0000:00:00 00:00' and you would like to have (NULL) values in it, you can do the following in f.e. Heidisql:

update your_table yt
set yt.wrong_date = NULL
WHERE CAST(yt.wrong_date AS CHAR(20)) = '0000-00-00 00:00:00'

Make sure that the date field accepts (NULL) values

Don't do this with Mariadb, it is not supported

Last update: Wed, 28 Nov 2018 10:34:09