If you want to treat the zero date '0000-00-00 00:00:00' as if it were NULL, you can explicitly check for it in your query:
~~sql~~
SELECT * FROM t1 WHERE enddate = '0000-00-00 00:00:00' OR enddate > '2025-01-01 00:00:00';
Alternatively, if you want to allow NULL values in the enddate column, you should change the table definition to allow NULL:
~~sql~~
CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, enddate datetime NULL, -- Allow NULL values PRIMARY KEY (id) );
Then you can insert NULL values and use the IS NULL operator as intended:
~~sql~~
INSERT INTO t1(enddate) VALUES (NULL); SELECT * FROM t1 WHERE enddate IS NULL OR enddate > '2025-01-01 00:00:00';
The IS NULL operator will not match the zero date '0000-00-00 00:00:00' because it is not NULL.
If you want to treat the zero date as NULL, you need to explicitly check for it or change your table to allow NULL values.
for more information ##[email protected] ##https://www.fiverr.com/s/8zYQaL4