0

I know, it's ugly but things used to work and we can't change this :

#1525 - Incorrect DATETIME value: ''

For a query

SELECT * FROM table WHERE date_change=''

Is there a SQL mode for MySQL 8? Or any idea?

underscore_d
  • 6,309
  • 3
  • 38
  • 64
David N
  • 118
  • 1
  • 7
  • DATETIME column cannot contain empty string. So look carefully in the table what is the value which you want to check for. Maybe this is NULL? if so then you must use `WHERE date_change IS NULL`. – Akina May 18 '21 at 17:19

2 Answers2

1

see: https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_no_zero_in_date

If sql_mode has 'NO_ZERO_IN_DATE' then you cannot have a zero_date (or datetime).

Luuk
  • 12,245
  • 5
  • 22
  • 33
  • Thanks for this answer, I did try this before. But that's not work for ''. I know, it's a bad query, but it worked on mysql 5.7. (and I can't change myself the query). S – David N May 19 '21 at 09:40
0
SET @@sql_mode := REPLACE(@@sql_mode, 'NO_ZERO_IN_DATE', '');

will do it

Mr Heelis
  • 2,370
  • 4
  • 24
  • 34