<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="year">
      </a>
      13.2.4 The YEAR Type
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045213518416">
  </a>
  <a class="indexterm" name="idm46045213517344">
  </a>
  <p>
   The
   <code class="literal">
    YEAR
   </code>
   type is a 1-byte type used to
        represent year values. It can be declared as
   <code class="literal">
    YEAR
   </code>
   with an implicit display width of 4
        characters, or equivalently as
   <code class="literal">
    YEAR(4)
   </code>
   with
        an explicit display width.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    he
    <a class="link" href="year.html" title="13.2.4 The YEAR Type">
     <code class="literal">
      YEAR(4)
     </code>
    </a>
    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, use
    <a class="link" href="year.html" title="13.2.4 The YEAR Type">
     <code class="literal">
      YEAR
     </code>
    </a>
    without a
          display width, which has the same meaning.
   </p>
  </div>
  <p>
   MySQL displays
   <code class="literal">
    YEAR
   </code>
   values in
   <em class="replaceable">
    <code>
     YYYY
    </code>
   </em>
   format, with a range of
   <code class="literal">
    1901
   </code>
   to
   <code class="literal">
    2155
   </code>
   , and
   <code class="literal">
    0000
   </code>
   .
  </p>
  <p>
   <code class="literal">
    YEAR
   </code>
   accepts input values in a variety of
        formats:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      As 4-digit strings in the range
      <code class="literal">
       '1901'
      </code>
      to
      <code class="literal">
       '2155'
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      As 4-digit numbers in the range
      <code class="literal">
       1901
      </code>
      to
      <code class="literal">
       2155
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      As 1- or 2-digit strings in the range
      <code class="literal">
       '0'
      </code>
      to
      <code class="literal">
       '99'
      </code>
      . MySQL converts values in the
            ranges
      <code class="literal">
       '0'
      </code>
      to
      <code class="literal">
       '69'
      </code>
      and
      <code class="literal">
       '70'
      </code>
      to
      <code class="literal">
       '99'
      </code>
      to
      <code class="literal">
       YEAR
      </code>
      values in the ranges
      <code class="literal">
       2000
      </code>
      to
      <code class="literal">
       2069
      </code>
      and
      <code class="literal">
       1970
      </code>
      to
      <code class="literal">
       1999
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      As 1- or 2-digit numbers in the range
      <code class="literal">
       0
      </code>
      to
      <code class="literal">
       99
      </code>
      . MySQL converts values in the
            ranges
      <code class="literal">
       1
      </code>
      to
      <code class="literal">
       69
      </code>
      and
      <code class="literal">
       70
      </code>
      to
      <code class="literal">
       99
      </code>
      to
      <code class="literal">
       YEAR
      </code>
      values in the ranges
      <code class="literal">
       2001
      </code>
      to
      <code class="literal">
       2069
      </code>
      and
      <code class="literal">
       1970
      </code>
      to
      <code class="literal">
       1999
      </code>
      .
     </p>
     <p>
      The result of inserting a numeric
      <code class="literal">
       0
      </code>
      has a
            display value of
      <code class="literal">
       0000
      </code>
      and an internal
            value of
      <code class="literal">
       0000
      </code>
      . To insert zero 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>
    </li>
    <li class="listitem">
     <p>
      As the result of functions that return a value that is
            acceptable in
      <code class="literal">
       YEAR
      </code>
      context, such as
      <a class="link" href="date-and-time-functions.html#function_now">
       <code class="literal">
        NOW()
       </code>
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   If strict SQL mode is not enabled, MySQL converts invalid
   <code class="literal">
    YEAR
   </code>
   values to
   <code class="literal">
    0000
   </code>
   . In
        strict SQL mode, attempting to insert an invalid
   <code class="literal">
    YEAR
   </code>
   value produces an error.
  </p>
  <p>
   See also
   <a class="xref" href="two-digit-years.html" title="13.2.9 2-Digit Years in Dates">
    Section 13.2.9, “2-Digit Years in Dates”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
