The following query works
select date(str_to_date("08-Nov-2005 22:07","%d-%M-%Y %H:%i:%S"))
As expected, it returns
2005-11-08
The following query also works
select date(str_to_date("XXXX","%d-%M-%Y %H:%i:%S"))
As expected, it returns
NULL
I should note there is a warning, but it doesn't stop the query from executing and returning a NULL result
show warnings
yields
But the problem occurs when I try to create a table from the result.
This works
CREATE TABLE myTable AS select date(str_to_date("08-Nov-2005 22:07","%d-%M-%Y %H:%i:%S"))
But this does not
CREATE TABLE myTable AS select date(str_to_date("XXXX","%d-%M-%Y %H:%i:%S"))
Error message is
Incorrect datetime value: 'XXXX' for function str_to_date
This is a very simple toy example, but I am trying to create a much larger table with many date values correctly parsed and it has the same effect.
What am I doing wrong?