title: MySQL: Calculated Column Based on Date Range
body: <p>How does one create a calculated column that yields the value of 1 if a date falls within 2015, else 0?</p>
  
  <p>I spent yesterday googling, and searching StackOverflow, for solutions to no avail. From what I learned about CASE WHEN, BETWEEN, and CAST, I put together the below SQL script.</p>
  
  <p>However, the below (truncated) script yields all 0's, despite having corresponding Prescreen dates in 2015, 2016, and even dates of 0000-00-00, as follows:
  <a href="https://i.stack.imgur.com/hn6Nj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hn6Nj.png" alt="enter image description here"></a></p>
  
  <pre><code>SELECT 
  table_r.R_Number,
  table_c.ref_num,
  DATE(STR_TO_DATE(table_c.Prescreen, '%d-%b-%y')) AS Prescreen,
  CASE
      WHEN Prescreen BETWEEN CAST('2015-01-01' AS DATE) AND CAST('2015-12-31' AS DATE) THEN 1
      ELSE 0
  END AS YTD2015_Prescreen,
  table_r.Region,
  FROM
  table_c
      INNER JOIN
  table_r ON table_c.R_Number = table_r.R_Number
  WHERE
  table_c.Int &lt;&gt; ''
  ;
  </code></pre>
  
  <p>I humbly ask you to lend me your genius.  Thank you.  :)</p>