I'm having trouble running MySQL REGEXP_SUBSTR within STR_TO_DATE to extract a date from a text field.
If can run the following query, and use REGEXP_SUBSTR to properly extract the date string.
SELECT REGEXP_SUBSTR('12/9/97 - Ependymoma!', '[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,2}');
# '12/9/97'
If I hard code the date string in STR_TO_DATE, I can properly convert the date string to a DATE.
SELECT STR_TO_DATE('12/9/97', '%m/%d/%y');
# '1997-12-09'
However, if I call the REGEXP_SUBSTR within STR_TO_DATE it returns NULL.
SELECT STR_TO_DATE(REGEXP_SUBSTR('12/9/97 - Ependymoma!', '[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,2}'), '%m/%d/%y');
# NULL
I've been struggling with this. Any direction would be appreciated. Thanks.