title: Oracle select dates based on year returning inconsistent results
body: <p>I'm getting a peculiar problem with an Oracle view I've modified. The idea is I have a base table that stores all election candidates and also has an election date column, telling us what election this candidate was part of, like so.</p>
  
  <pre><code>NAME       | ELECTION_DATE
  ---------------------------
  John Smith | 01-APR-2011
  Alan Cooper| 02-MAY-2013
  </code></pre>
  
  <p>The ELECTION_DATE column is stored as a date. We constructed 2 views for 2011 and 2013, using the following statment for 2011.</p>
  
  <pre><code>where election_date &gt;= to_date(2011,'yyyy') and election_date &lt; to_date(2012,'yyyy')
  </code></pre>
  
  <p>Which we thought would pick up just the John Smith record above, but it didn't. The peculiar thing was that when we did this for the 2013 view.</p>
  
  <pre><code>where election_date &gt;= to_date(2013,'YYYY') and election_date &lt; to_date(2014,'YYYY')
  </code></pre>
  
  <p>It DID get just the Alan Cooper record. Even more peculiar is that if we did this for the 2011 view.</p>
  
  <pre><code>where election_date &gt;= to_date(2010,'yyyy') and election_date &lt; to_date(2011,'yyyy')
  </code></pre>
  
  <p>We got just the John Smith record and not the Alan Cooper record, which is what we wanted but not what we expected. </p>
  
  <p>We then changed them both to between statements and they behaved exactly the same i.e. between 2010 and 2011 got the John Smith record, between 2011 and 2012 got nothing and between 2013 and 2014 got the Alan Cooper record.</p>
  
  <p>Whilst I was writing this my colleague managed to fix it by using this more explicit statement.</p>
  
  <pre><code>where election_date between  '01-JAN-2011' AND '01-JAN-2012'
  </code></pre>
  
  <p>But I still want to know why the above statements still worked so strangely? Something I am missing about using to_date functions for just years maybe?</p>