title: Count distinct dates within timestamp by Month SQL
body: <p>I would like to count the number of distinct dates within each month. </p>
  
  <p>I have a data set that looks like this:</p>
  
  <pre><code>TIMESTAMP 
  ------------------
  2017-10-25 14:39:51 
  2017-10-25 15:00:51
  2017-11-10 02:39:42
  2018-09-24 14:39:55
  2018-09-25 13:25:01
  2019-02-12 12:23:44
  ...
  </code></pre>
  
  <p>So my expected output would be:</p>
  
  <pre><code>year_month | count
  2017-10    2
  2018-09    2
  2019-02    1
  </code></pre>
  
  <p>I have tried the following code so far, but it is returning incorrect results:</p>
  
  <pre><code>WITH F AS(
      SELECT concat(YEAR(TIMESTAMP), MONTH(TIMESTAMP)) AS year_month
          FROM tbl
          WHERE TYPE = 'Site'
              AND TO_SITE = 'location'
  )
  
  SELECT count(year_month), year_month
      FROM F
      GROUP BY year_month
  </code></pre>
  
  <p>I do not need to worry about the time of day. I just want to count the distinct days in each month. Thank you in advance for your help.</p>