title: SQL Server datetime in 12AM/PM format without the millisecond
body: <p>I would like to return my datetime data to the following format:</p>
  
  <p>mm/dd/yy hh:mi:ssAM</p>
  
  <p>According to the CONVERT <a href="http://msdn.microsoft.com/en-us/library/ms187928.aspx" rel="nofollow">documentation</a> the closest thing that matches my spec is '131'</p>
  
  <pre><code>SELECT CONVERT(varchar, GETDATE(), 131)
  </code></pre>
  
  <p>but it doesn't exactly match my specifications.</p>
  
  <hr>
  
  <p>EDIT:
  I ended up doing the date formatting in my application layer which is PHP.</p>
  
  <p>It was as simple as using the <a href="http://php.net/manual/en/function.strtotime.php" rel="nofollow">strtotime</a> function to generate a UNIX timestamp and pass it into <code>date</code> funciton.</p>
  
  <pre><code>$date = date('m/d/Y g:ia', strtotime($row['date_time']));
  </code></pre>