'MYSQL can't update date but in happens very seldom
MYSQL can't update date but in happens very seldom
I have it error very seldom(few time by month),for some dates like this. It isn't problem of code. I can't update DB field with the same date by IDE too.
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2022-03-13 02:59:14' for column 'date' at row 1 (SQL: update
logssetlogs.date= 2022-03-13 02:59:14 whereID= 2)
Other date not updates: 2022-03-13 02:58:16, 2022-03-13 02:57:15, 2022-03-13 02:55:15, 2022-03-13 02:54:16, 2022-03-13 02:53:14, 2022-03-13 02:52:15, 2022-03-13 02:51:15 .
Updates successfully: 2022-04-11 09:17:07
My query:
update logs set logs.date = '2022-03-13 02:59:14' where ID = 2;
Guys do you have any ideas, why in happens?
Table info:
DB info:
Dialect: MySQL DBMS: MySQL (ver. 5.7.29-0ubuntu0.16.04.1)
Case sensitivity: plain=exact, delimited=exact
Driver: MariaDB Connector/J (ver. 2.6.0, JDBC4.2)
charset = utf8;
Solution 1:[1]
There's nothing wrong with these values. See below
Please give us the table definition and actuel sql update query that you are running.
CREATE TABLE d (d datetime); INSERT INTO d VALUES ('2022-02-02');? ?
update d set d = '2022-03-13 02:58:16'; select d from d; update d set d = '2022-03-13 02:57:15'; select d from d; update d set d = '2022-03-13 02:55:15'; select d from d; update d set d = '2022-03-13 02:54:16'; select d from d; update d set d = '2022-03-13 02:53:14'; select d from d; update d set d = '2022-03-13 02:52:15'; select d from d; update d set d = '2022-03-13 02:51:15'; select d from d;? | d | | :------------------ | | 2022-03-13 02:58:16 | ? | d | | :------------------ | | 2022-03-13 02:57:15 | ? | d | | :------------------ | | 2022-03-13 02:55:15 | ? | d | | :------------------ | | 2022-03-13 02:54:16 | ? | d | | :------------------ | | 2022-03-13 02:53:14 | ? | d | | :------------------ | | 2022-03-13 02:52:15 | ? | d | | :------------------ | | 2022-03-13 02:51:15 |
db<>fiddle here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

