Search code examples
mysqldatetimestr-to-date

MySQL Database Error: Incorrect datetime value: '2015/06/08' for function str_to_date


I'm trying to insert a date from a string in another table. The SELECT statement provides no error while the INSERT statement provides the error "Incorrect datetime value: '2015/06/08' for function str_to_date"
The data in the 1CON field is 2015/06/08

INSERT INTO dest
SELECT COALESCE(STR_TO_DATE(1CON, '%m/%d/%Y'),
STR_TO_DATE(1CON, '%Y/%m/%d')) 
FROM origin WHERE REC=4953;

And the SELECT statement:

SELECT COALESCE(STR_TO_DATE(1CON, '%m/%d/%Y'),
STR_TO_DATE(1CON, '%Y/%m/%d'))
FROM origin WHERE REC=4953;

Solution

  • insert dates as '2015-06-02' kinda format

    insert datetimes as '2015-06-02 14:02:28'

    yes, for June 2