SQL将'mm / dd / yy'字符串转换为日期格式

问题描述 投票:0回答:1

我有一个名为templog的表,我有一个名为'tdate'的日期列,它以'mm / dd / yy'格式存储一个字符串。我尝试使用以下语法进行转换,但收到错误。

SELECT convert(datetime,tdate,110) from templog

SQL查询:文档

SELECT转换(datetime,tdate,110)来自templog LIMIT 0,25 MySQL说:文档

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'tdate,110) from templog LIMIT 0, 25' at line 1

关于我做错了什么的任何想法?

mysql sql date syntax mariadb
1个回答
1
投票

对于MariaDB,你想要str_to_date()

SELECT str_to_date(tdate, '%m/%d/%y')
FROM templog
© www.soinside.com 2019 - 2024. All rights reserved.