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 manually too.
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2022-03-13 02:59:14' for column 'date' at row 1 (SQL: update
logs
setlogs
.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
Guys do you have any ideas, why in happens?
CodePudding user response:
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