Help with mysql str-to-date

I can't get this to work. I want to use str_to_date to convert a date string. Here is my insert statement.

INSERT INTO cars(carno, color, date) VALUES ('1', 'brown', STR_TO_DATE('$date', 'm%/%d/%Y'))

Can someone please tell me where I am going wrong? The date in my variable is 12/12/2002

Any???

+3
source share
2 answers

A simple but effective typo, it %mis not m%.;)

+4
source

Most likely you have mixed up m%:

"INSERT INTO cars(carno, color, date) VALUES ('1', 'brown', STR_TO_DATE('$date', '%m/%d/%Y'))"
+2
source

Source: https://habr.com/ru/post/1718891/


All Articles