error code 1292 incorrect date value mysql

后端 未结 5 1813
滥情空心
滥情空心 2020-12-01 03:39

I have a table

`CREATE  TABLE IF NOT EXISTS `PROGETTO`.`ALBERGO` (

`ID` INT(11) NOT NULL COMMENT \'identificativo dell\\\' albergo\' ,
`nome` VARCHAR(45) N         


        
相关标签:
5条回答
  • 2020-12-01 04:18

    Insert date in the following format yyyy-MM-dd example,

    INSERT INTO `PROGETTO`.`ALBERGO`(`ID`, `nome`, `viale`, `num_civico`, `data_apertura`, `data_chiusura`, `orario_apertura`, `orario_chiusura`, `posti_liberi`, `costo_intero`, `costo_ridotto`, `stelle`, `telefono`, `mail`, `web`, `Nome-paese`, `Comune`) 
    VALUES(0, 'Hotel Centrale', 'Via Passo Rolle', '74', '2012-05-01', '2012-09-31', '06:30', '24:00', 80, 50, 25, 3, '43968083', 'info@hcentrale.it', 'http://www.hcentrale.it/', 'Trento', 'TN')
    
    0 讨论(0)
  • 2020-12-01 04:27

    I happened to be working in localhost , in windows 10, using WAMP, as it turns out, Wamp has a really accessible configuration interface to change the MySQL configuration. You just need to go to the Wamp panel, then to MySQL, then to settings and change the mode to sql-mode: none.(essentially disabling the strict mode) The following picture illustrates this.

    0 讨论(0)
  • 2020-12-01 04:39

    I was having the same issue in Workbench plus insert query from C# application. In my case using ISO format solve the issue

    string value = date.ToString("yyyy-MM-dd HH:mm:ss");
    
    0 讨论(0)
  • 2020-12-01 04:40

    An update. Dates of the form '2019-08-00' will trigger the same error. Adding the lines:

    [mysqld]
    
    sql_mode="NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 
    

    to mysql.cnf fixes this too. Inserting malformed dates now generates warnings for values out of range but does insert the data.

    0 讨论(0)
  • 2020-12-01 04:41

    With mysql 5.7, date value like 0000-00-00 00:00:00 is not allowed.

    If you want to allow it, you have to update your my.cnf like:

    sudo nano /etc/mysql/my.cnf
    

    find

    [mysqld]
    

    Add after:

    sql_mode="NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    

    Restart mysql service:

    sudo service mysql restart
    

    Done!

    0 讨论(0)
提交回复
热议问题