Date values with 2-digit years are ambiguous because the century is unknown. 具有两位数年份的日期值不明确,因为世纪未知。Such values must be interpreted into 4-digit form because MySQL stores years internally using 4 digits.这些值必须被解释为4位数的形式,因为MySQL在内部使用4位数存储年份。
For 对于DATETIME
, DATE
, and TIMESTAMP
types, MySQL interprets dates specified with ambiguous year values using these rules:DATETIME
、DATE
和TIMESTAMP
类型,MySQL使用以下规则解释使用不明确年份值指定的日期:
Year values in the range 范围为00-69
become 2000-2069
.00-69
的年份值变为2000-2069
。
Year values in the range 70-99
become 1970-1999
.70-99
之间的年份值变为1970-1999
。
For 对于YEAR
, the rules are the same, with this exception: A numeric 00
inserted into YEAR
results in 0000
rather than 2000
. YEAR
,规则是相同的,但有一个例外:在年份中插入数字00
,结果是0000
而不是2000
。To specify zero for 若要为YEAR
and have it be interpreted as 2000
, specify it as a string '0'
or '00'
.YEAR
指定零并将其解释为2000
,请将其指定为字符串'0'
或'00'
。
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 values you require, you must provide unambiguous input containing 4-digit year values.如果MySQL使用的规则没有生成所需的值,则必须提供包含4位年份值的明确输入。
ORDER BY
properly sorts YEAR
values that have 2-digit years.ORDER BY
对具有两位数年份的年份值进行正确排序。
Some functions like 一些函数如MIN()
and MAX()
convert a YEAR
to a number. MIN()
和MAX()
将YEAR
转换为数字。This means that a value with a 2-digit year does not work properly with these functions. 这意味着具有两位数年份的值不能与这些函数一起正常工作。The fix in this case is to convert the 本例中的修复方法是将YEAR
to 4-digit year format.YEAR
转换为4位数的年份格式。