更改 MYSQL 日期格式

2022-01-15 00:00:00 format date mysql

我在 MYSQL 中有一个表,其中 3 列有日期,而且它们的格式不符合要求.

I have a table in MYSQL of which 3 columns have dates and they are formatted in the not desired way.

目前我有:mm/dd/yyyy,我想将这些日期更改为 dd/mm/yyyy.

Currently I have: mm/dd/yyyy and I want to change those dates into dd/mm/yyyy.

表名是 Vehicles,列名是:

Table name is Vehicles and the columns names are:

CRTD
INSR
SERD

推荐答案

您当前列的数据类型不是 date 对吗?您需要先使用 STR_TO_DATE() 将其转换为日期,然后再转换回字符串

Your current datatype for your column is not date right? you need to convert it to date first using STR_TO_DATE() and convert back to string

SELECT DATE_FORMAT(STR_TO_DATE(colName, '%c/%d/%Y'), '%d/%c/%Y')
FROM table1

相关文章