Error while inserting date - Incorrect date value:

前端 未结 7 1691
花落未央
花落未央 2020-12-09 08:31

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

7条回答
  •  囚心锁ツ
    2020-12-09 08:56

    You need to convert the date to YYYY-MM-DD in order to insert it as a MySQL date using the default configuration.

    One way to do that is STR_TO_DATE():

    insert into your_table (...)
    values (...,str_to_date('07-25-2012','%m-%d-%Y'),...);
    

提交回复
热议问题