Documentation Home
MySQL 9.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.2Mb
PDF (A4) - 41.3Mb
Man Pages (TGZ) - 262.8Kb
Man Pages (Zip) - 368.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


13.2.4 The YEAR Type

TheYEAR type is a 1-byte type used to represent year values. It can be declared asYEAR with an implicit display width of 4 characters, or equivalently asYEAR(4) with an explicit display width.

Note

heYEAR(4) data type using an explicit display width is deprecated and you should expect support for it to be removed in a future version of MySQL. Instead, useYEAR without a display width, which has the same meaning.

MySQL displaysYEAR values inYYYY format, with a range of1901 to2155, and0000.

YEAR accepts input values in a variety of formats:

  • As 4-digit strings in the range'1901' to'2155'.

  • As 4-digit numbers in the range1901 to2155.

  • As 1- or 2-digit strings in the range'0' to'99'. MySQL converts values in the ranges'0' to'69' and'70' to'99' toYEAR values in the ranges2000 to2069 and1970 to1999.

  • As 1- or 2-digit numbers in the range0 to99. MySQL converts values in the ranges1 to69 and70 to99 toYEAR values in the ranges2001 to2069 and1970 to1999.

    The result of inserting a numeric0 has a display value of0000 and an internal value of0000. To insert zero and have it be interpreted as2000, specify it as a string'0' or'00'.

  • As the result of functions that return a value that is acceptable inYEAR context, such asNOW().

If strict SQL mode is not enabled, MySQL converts invalidYEAR values to0000. In strict SQL mode, attempting to insert an invalidYEAR value produces an error.

See alsoSection 13.2.9, “2-Digit Years in Dates”.