mysql 更新带斜线的日期时间日期

mysql update datetime date with slashes

如何更新 mysql

中的 DATETIME 列

尝试使用:(以及许多其他)

我不太关心日期在数据库中的格式,但是需要能够使用 01/01/2001 01:01 格式更新当前行

update contacts set replydate=STR_TO_DATE('1/9/2020 13:32', '%m/%d/%Y hh:mm') where id='3';

该日期不是当前日期,这些都是跨页 sheet 中的不同日期,它们都具有相同的格式。

MariaDB [ddcontactsdb]> describe contacts;
+----------------+-----------------+------+-----+-------------------+-----------------------------+
| Field          | Type            | Null | Key | Default           | Extra                       |
+----------------+-----------------+------+-----+-------------------+-----------------------------+
| replydate      | datetime        | YES  |     | NULL              |                             | 
+----------------+-----------------+------+-----+-------------------+-----------------------------+

您必须使用这种格式:

update contacts set replydate=STR_TO_DATE('1/9/2020 13:32', '%m/%d/%Y %H:%i') where id='3';

因为 m 代表月份,i 代表分钟,H 代表小时 00-23