title: Selecting distinct dates from datetime column in a table
body: <p>I have a table</p>
  
  <pre><code>id | message | date_posted
  1  | testing | 2011-03-08 03:15:13
  2  | testing | 2011-03-06 03:15:13
  3  | testing | 2011-03-08 03:15:13
  </code></pre>
  
  <p>And need a query where I return a list of distinct dates in desc order. I tried to formulate a query like so</p>
  
  <pre><code>SELECT DISTINCT CAST(`date_posted` AS DATE) AS dateonly FROM table
  </code></pre>
  
  <p>This gives me dates but they're not distinct and have duplicates.</p>
  
  <p>Any ideas? (Using php/mysql)</p>
  
  <p><strong>MAJOR EDIT:</strong></p>
  
  <p>Forgot an important piece of information. I'm trying to get unique dates based on month and year.</p>
  
  <pre><code>2011-03-08 03:15:13
  2011-03-06 03:15:13
  2011-03-02 03:15:13
  2011-03-01 03:15:13
  2011-02-01 03:15:13
  </code></pre>
  
  <p>So running the query would only return [2011-03-dd,2011-02-01] (dd being any day)</p>
  
  <p>Apologize for not stating this.</p>