title: DB2 - Select values based on number of days in current month
body: <p>I have table something like below. </p>
  
  <p>TABLE NAME (issues):</p>
  
  <pre><code>ID  ISSUE_ID  CREATED_DATE 
  1   101       15 July 2016 
  2   102       13 July 2016 
  3   103       10 July 2016 
  4   104       8 July 2016  
  5   103       7 July 2016  
  6   104       19 June 2016 
  7   103       10 June 2016 
  8   104       1 June 2016  
  </code></pre>
  
  <p>I want retrieve number of issues(count) that was opened in last 30/31/28 days based on number of days in current month. </p>
  
  <p>For example, 
  In the month of July, we have 31 days, so I want to retrieve issues that got opened in last 31 days. </p>
  
  <p>If in case of June, we have only 30 days, so I have to retrieve issues that was opened in last 30 days. </p>
  
  <p>In DB2, number of days on this month can be retrieved by </p>
  
  <pre><code>DAY(LAST_DAY(DATE(current timestamp)))
  </code></pre>
  
  <p>I am still confused how to apply it to a query. 
  I have a very limited knowledge on queries. </p>
  
  <p>Thanks in advance.</p>
  
  <p>The following query didn't work. </p>
  
  <pre><code>SELECT 
    count(*)
    FROM issues
  WHERE
    MONTH(CREATED_DATE) &gt; (MONTH( DATE(current timestamp) ) - 1 MONTH)
    AND 
    DAY(DATE (CREATED_DATE)) &gt; DAY(DATE(current timestamp))
  </code></pre>