Im trying to convert a date in the form either dd/mm/yy
with
from concertlistts as c
SELECT STR_TO_DATE(str(c.Date)), "%e, %m, %y"));
but when I try to run it it says syntax errors
How do I fix this
I’ve tried
from concertlistts as c
SELECT STR_TO_DATE(str(c.Date)), "%e, %m, %y"));
2
Answers
Clauses of the SQL
SELECT
statement need to be in the right order.SELECT
comes beforeFROM
. Study the proper syntax in the manual.MySQL has no function
STR()
, and you don’t need it in this case.If your date string has slashes (
/
), then use the same character in your format string, not commas (,
).Here’s a demo I tested with MySQL 8.4.3:
Below is the correct syntax.
https://dbfiddle.uk/xkWalE9c