MySQL tutorial: YEAR DATA TYPE [EN]
top of page
CerebroSQL

MySQL: 

YEAR DATA TYPE

YEAR[(4)]

A year in 4-digit format. MySQL displays YEAR values in YYYY format,
but permits assignment of values to YEAR columns using either strings
or numbers. Values display as 1901 to 2155, or 0000.

For additional information about YEAR display format and interpretation
of input values, see https://dev.mysql.com/doc/refman/8.0/en/year.html.

*Note*:

As of MySQL 8.0.19, the YEAR(4) data type with an explicit display
width is deprecated and support for it will be removed in a future
MySQL version. Instead, use YEAR without a display width, which has the
same meaning.

MySQL 8.0 does not support the 2-digit YEAR(2) data type permitted in
older versions of MySQL. For instructions on converting to 4-digit
YEAR, see 2-Digit YEAR(2) Limitations and Migrating to 4-Digit YEAR
(https://dev.mysql.com/doc/refman/5.7/en/migrating-from-year2.html) in
MySQL 5.7 Reference Manual (https://dev.mysql.com/doc/refman/5.7/en/).

Example

bottom of page