To store such kind of dates where the day, month or both month & day are zero we must have to set mode of sql to allow_invalid_dates mode.
mysql> set sql_mode = 'allow_invalid_dates'; Query OK, 0 rows affected (0.00 sec) mysql> insert into check_date(OrderDate) values('2017-00-00'); Query OK, 1 row affected (0.06 sec) mysql> select * from check_date; +-------------+ | OrderDate | +-------------+ | 2017-00-00 | +-------------+ 1 row in set (0.00 sec)
Above query will insert the date in which both month & day values are zero.
mysql> insert into check_date(Orderdate) values ('2017-00-05'); Query OK, 1 row affected (0.07 sec) mysql> select * from check_date; +------------+ | Orderdate | +------------+ | 2017-00-00 | | 2017-00-05 | +------------+ 2 rows in set (0.00 sec)
Above query will insert the date in which month value is zero.
mysql> insert into check_date(Orderdate) values ('2017-05-00'); Query OK, 1 row affected (0.02 sec) mysql> select * from check_date; +------------+ | Orderdate | +------------+ | 2017-00-00 | | 2017-00-05 | | 2017-05-00 | +------------+ 3 rows in set (0.00 sec)
Above query will insert the date on which day value is zero.