title: how to extract the year from a date in Oracle?
body: <p>I dont understand why the following query does not work</p>
  
  <pre><code>SELECT stringdate, TO_DATE(TO_CHAR(stringdate),'YYYYMMDD') AS mydate,
  EXTRACT(YEAR FROM MYDATE) as myyear
  FROM data.repo data 
  WHERE ROWNUM &lt;10" 
  </code></pre>
  
  <p>It returns <code>ORA-00904: "MYDATE": invalid identifier</code></p>
  
  <p>However, just running </p>
  
  <pre><code>SELECT stringdate, TO_DATE(TO_CHAR(stringdate),'YYYYMMDD') AS mydate
  </code></pre>
  
  <p>gives correctly:</p>
  
  <pre><code>stringdate    MYDATE
  20150130 2015-01-30
  </code></pre>
  
  <p>This drives me crazy. What is the issue? Thanks!</p>