I\'m currently migrating a table with dates in VARCHAR
columns to a new table with DATE
columns. I managed to sanitize the string values in the old
A possible workaround is to turn off strict mode, either for the whole server, for a particular session, or for just a few statements. For example:
set @old_sql_mode = @@sql_mode;
set sql_mode = '';
-- Run some statements which may result in error
set sql_mode = @old_sql_mode;
Additional Info
MySQL Documentation
In addition to @EduardoDennis answer use NULLIF
to filter out zero dates:
INSERT INTO newFancyTable (created_at)
SELECT nullif(str_to_date(created, '%Y-%m-%d'), from_days(0)) FROM oldCrappyTable;
See my full answer here.