<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="two-digit-years">
      </a>
      13.2.9 2-Digit Years in Dates
     </h3>
    </div>
   </div>
  </div>
  <p>
   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.
  </p>
  <p>
   For
   <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
    <code class="literal">
     DATETIME
    </code>
   </a>
   ,
   <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
    <code class="literal">
     DATE
    </code>
   </a>
   , and
   <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
    <code class="literal">
     TIMESTAMP
    </code>
   </a>
   types, MySQL interprets
        dates specified with ambiguous year values using these rules:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Year values in the range
      <code class="literal">
       00-69
      </code>
      become
      <code class="literal">
       2000-2069
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Year values in the range
      <code class="literal">
       70-99
      </code>
      become
      <code class="literal">
       1970-1999
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   For
   <code class="literal">
    YEAR
   </code>
   , the rules are the same, with this
        exception: A numeric
   <code class="literal">
    00
   </code>
   inserted into
   <code class="literal">
    YEAR
   </code>
   results in
   <code class="literal">
    0000
   </code>
   rather than
   <code class="literal">
    2000
   </code>
   . To specify zero for
   <code class="literal">
    YEAR
   </code>
   and have it be interpreted as
   <code class="literal">
    2000
   </code>
   , specify it as a string
   <code class="literal">
    '0'
   </code>
   or
   <code class="literal">
    '00'
   </code>
   .
  </p>
  <p>
   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.
  </p>
  <p>
   <code class="literal">
    ORDER BY
   </code>
   properly sorts
   <a class="link" href="year.html" title="13.2.4 The YEAR Type">
    <code class="literal">
     YEAR
    </code>
   </a>
   values that have 2-digit
        years.
  </p>
  <p>
   Some functions like
   <a class="link" href="aggregate-functions.html#function_min">
    <code class="literal">
     MIN()
    </code>
   </a>
   and
   <a class="link" href="aggregate-functions.html#function_max">
    <code class="literal">
     MAX()
    </code>
   </a>
   convert a
   <a class="link" href="year.html" title="13.2.4 The YEAR Type">
    <code class="literal">
     YEAR
    </code>
   </a>
   to a number. 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
   <a class="link" href="year.html" title="13.2.4 The YEAR Type">
    <code class="literal">
     YEAR
    </code>
   </a>
   to 4-digit year format.
  </p>
 </div>
 <br/>
</div>
