title: Getting the current month?
body: <p>In an SQL query I need to get some data only from the current month. To get a specific month, I would do this. </p>
  
  <pre><code>select (case when date_part('month', date) = 3 and date_part('year', date) = 2014 then amount end)
         ,(case when date_part('month', date) = 3 and date_part('year', date) = 2013 then amount end
  from &lt;table&gt;
  </code></pre>
  
  <p>My main purpose is to get the current month for this year, and the same month from the previous year. </p>
  
  <p>This is what I would try</p>
  
  <pre><code>select current_month(case when date_part('year', date) = 2014 then amount end) as current
         ,(case when current_month and date_part('year', date) = 2013 then amount end) as last_year
  </code></pre>