title: Postgresql select between month range
body: <p>I have table with one of the columns as date in 'YYYY-MM-DD' format. Can I use select to get all data in a monthly range? Say I want all the data from 2012-01-xx to 2013-04-xx. So I am basically looking for a SQL query like the one given below:</p>
  
  <pre><code>SELECT * FROM table WHERE date IN BETWEEN '2012-01' AND '2013-04' (INVALID QUERY)
  </code></pre>
  
  <p>Since every month begin with '01' I can modify the above query to adjust the start condition.</p>
  
  <pre><code>SELECT * FROM table WHERE date IN BETWEEN '2012-01-01' AND '2013-04' (INVALID QUERY)
  </code></pre>
  
  <p>Now the issue comes with the enddate. I have to manually calculate the last date for the given month, taking all factors in account like length of the month, leap year etc., as the query fails if the given date is invalid. So currently I am doing something like this:</p>
  
  <pre><code>SELECT * FROM table WHERE date IN BETWEEN '2012-01-01' AND 'VALID_MONTH_END_DATE' (VALID Query)
  </code></pre>
  
  <p>I want to know if there is any way to avoid this valid end date calculation?</p>
  
  <p><strong>Clarification</strong></p>
  
  <p>I have thought above the first day of the next month, but even then I'll have to apply some logic say, if its December, the next month would be January of next year. I wanted to know if a SQL only solution is possible?</p>