I want to update data in mysql table on basis of date field value.
Table consist of four fields (id, file_id, date_of_purchase, error). date_of_purchase and error are varchar fields.
Now i want to update error field if value in date is not a valid date. I tried with STR_TO_DATE()
function but it is not working in where clause
in update query
Here is my query
UPDATE `temp_bulk_upload_data` SET `error`= 'Date of purchase: Date of purchase should be a valid date' WHERE `file_id`='190' AND STR_TO_DATE(`date_of_purchase`, '%m/%d/%Y') IS NULL AND (`date_of_purchase` != '' OR `date_of_purchase` IS NOT NULL)
In this query i am getting this error:
Error in query (1411): Incorrect datetime value: '27/8/2018' for function str_to_date