11.3.4. Y2K Issues and Date Types
As discussed in Section 1.4.5, “Year 2000 Compliance”, MySQL
itself is year 2000 (Y2K) safe. However, particular input values
presented to MySQL may not be Y2K safe. Any value containing a
two-digit year is ambiguous, because the century is unknown.
Such values must be interpreted into four-digit form because
MySQL stores years internally using four digits.
For DATETIME
, DATE
,
TIMESTAMP
, and YEAR
types,
MySQL interprets dates with ambiguous year values using the
following rules:
Remember that these rules are only heuristics that provide
reasonable guesses as to what your data values mean. If the
rules used by MySQL do not produce the correct values, you
should provide unambiguous input containing four-digit year
values.
ORDER BY
properly sorts
YEAR
values that have two-digit years.
Some functions like MIN()
and
MAX()
convert a YEAR
to a
number. This means that a value with a two-digit year does not
work properly with these functions. The fix in this case is to
convert the TIMESTAMP
or
YEAR
to four-digit year format.