简体   繁体   English

在mysql 8.0中转换日期的任何格式

[英]Conversion of any format of date in mysql 8.0

I am trying to insert values into a table: 我正在尝试将值插入表中:

INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,convert(datetime,'13-JUL-2019',101),1100,NULL,20);

But I receive the error below: 但我收到以下错误:

You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near ''13-JUL-2019',101),1100,NULL,20)' at line 1. 检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的``13-JUL-2019',101),1100,NULL,20)'附近使用。

Tried different syntaxes, however I couldn't solve this. 尝试了不同的语法,但是我无法解决这个问题。 Please some one help. 请一些帮助。 Thank you. 谢谢。

The convert(datetime,'13-JUL-2019',101) syntax is for MS SQL Server / Sybase. convert(datetime,'13-JUL-2019',101)语法适用于MS SQL Server / Sybase。

Instead, use STR_TO_DATE . 而是使用STR_TO_DATE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM