I have a column called today
and the type is DATE
.
When I try to add the date in the format '07-25-2012'
I get the following error:
See Question&Answers more detail:osUnable to run query:Incorrect date value: '07-25-2012' for column
I have a column called today
and the type is DATE
.
When I try to add the date in the format '07-25-2012'
I get the following error:
See Question&Answers more detail:osUnable to run query:Incorrect date value: '07-25-2012' for column
As MySql accepts the date in y-m-d format in date type column, you need to STR_TO_DATE
function to convert the date into yyyy-mm-dd format for insertion in following way:
INSERT INTO table_name(today)
VALUES(STR_TO_DATE('07-25-2012','%m-%d-%y'));
Similary, if you want to select the date in different format other than Mysql format, you should try DATE_FORMAT
function
SELECT DATE_FORMAT(today, '%m-%d-%y') from table_name;