Select*fromdetail_bday;+----+---------+------------+ |Sr|Name |Birth_Date|+----+---------+------------+|1|Sa"/> Select*fromdetail_bday;+----+---------+------------+ |Sr|Name |Birth_Date|+----+---------+------------+|1|Sa">
Suppose if we store a date value "0000-00-00" in a MySQL table, then MySQL will return 0 when extracting the year value from such a date. It will not be in Year(2) or Year(4) format. To understand it, we use the following data from the "detail_bday" table -
mysql> Select * from detail_bday; +----+---------+------------+ | Sr | Name | Birth_Date | +----+---------+------------+ | 1 | Saurabh | 1990-05-12 | | 2 | Raman | 1993-06-11 | | 3 | Gaurav | 1984-01-17 | | 4 | Rahul | 1993-06-11 | | 5 | Sonia | 1993-11-31 | | 6 | Ram | 0000-00-00 | +----+---------+------------+ 6 rows in set (0.00 sec)
Now the following query will try to get the year value from the date "0000-00-00" -
mysql> Select Year(Birth_date) from detail_bday Where Name = 'Ram'; +------------------+ | Year(Birth_date) | +------------------+ | 0 | +------------------+ 1 row in set (0.00 sec)
The above result The set shows that MySQL returns 0 instead of giving the value in Year(2) or Year(4) format.
The above is the detailed content of In which format Year(2) or Year(4) will MySQL return the year value starting from the date "0000-00-00"?. For more information, please follow other related articles on the PHP Chinese website!