tags:

views:

48

answers:

2

I cannot 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

Anyone???

+2  A: 

A simple but yet effective typo, it's %m and not m%. ;)

Bobby
Oh my God!!!!! I cannot even believe I did that. Thanks!
I'm half blind over here and about an hour and a half later. :) It worked.
+1  A: 

It’s probably just that you interchanged m%:

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