-1

I am looking for a query resolution for one of insert scenarios in MySQL.

Below is the scenario:

create table test (test_date date);
insert  into test values (str_to_date('16/04/1991','%d/%m/%y'))

MySQL is not allowing me to insert this record and displays an error "Truncated incorrect value" I tried using IGNORE:

insert ignore into test values (str_to_date('16/04/1991','%d/%m/%y'))

but it captured year as 2019.

Please help.

thanks!

2 Answers2

1
insert  into test values (str_to_date('16/04/1991','%d/%m/%Y'))

It should be %Y for year

Please refer this page

fancyuserid
  • 145
  • 13
1

This is actually a warning, not an error, it happens because MySQL is running in Strict Mode. In Strict Mode, warnings become errors when trying to INSERT/UPDATE. To disable strict mode, you can put SET sql_mode = ''; in the beginning of your query.

Silidrone
  • 1,205
  • 4
  • 11
  • 27