更新时间:2023-02-12 20:48:00
您要使用STR_TO_DATE函数,而不要使用DATE_FORMAT.另外,我假设您只想更新格式错误的日期,所以我想您可以这样做:
You want to use STR_TO_DATE function, not DATE_FORMAT. Plus, I assume you only want to update the misformed dates, so I guess you could do this :
UPDATE your_table
SET date_field = DATE(STR_TO_DATE(date_field, '%m/%d/%Y'))
WHERE DATE(STR_TO_DATE(date_field, '%m/%d/%Y')) <> '0000-00-00';
P.S.表格包含列,而不包含字段.而且,您不应该使用字符串类型来保存日期,而应使用DATE类型
P.S. Tables contain columns, not fields. And you shouldn't use a string type to hold your dates, but the DATE type