title: Mysql - how to sort the date format with am/pm
body: <p>Please check the query.</p>
  
  <pre><code>SELECT DATE_FORMAT( CAST( CONCAT( table.date,  " ", table.time ) ) ,  '%p' ) 
  FROM table AS table
  
  Error:
  [hash]1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '), '%p') FROM exp_visitorsday as vd LIMIT 0, 30' at line 2
  </code></pre>
  
  <p>I have tried this query in following cases.</p>
  
  <pre><code>SELECT DATE_FORMAT( CAST( CONCAT( table.date,  " ", table.time ) as datetimecol ) as datetimecol,  '%p' ) 
  FROM table AS table
  
  SELECT DATE_FORMAT( CAST( CONCAT( table.date,  " ", table.time ) as datetimecol ),  '%p' ) 
  FROM table AS table
  </code></pre>
  
  <p>Sample data:</p>
  
  <pre><code>table.date =&gt; 01-08-2013
  table.time =&gt; 10:00 AM
  </code></pre>
  
  <p>How to do query? What's a problem in this query?</p>