title: Date formatting in MySQL for filtering by AngularJS date filter
body: <p>I'm using MySQL, AngularJS, and ngTable to build out my tabular data, and I'm having issues sorting.</p>
  
  <p>Database</p>
  
  <pre><code>`id` int(11) NOT NULL AUTO_INCREMENT,
  `packageid` int(11) NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,  // 2014-10-30 15:31:56
  `status` int(11) NOT NULL DEFAULT '1',
  </code></pre>
  
  <p>SQL</p>
  
  <pre><code>$query = $this-&gt;db-&gt;query( 
      "SELECT packageinstance.id, 
              packageinstance.created  // 2014-10-30 15:31:56
              DATE_FORMAT(packageinstance.created, '%b %e, %Y') as date, // Jan 1, 2014
              user.username, 
              status.name as status 
      FROM packageinstance 
      JOIN user   ON user.id   = packageinstance.creatorid 
      JOIN status ON status.id = packageinstance.status 
      WHERE    packageinstance.locationid = ? 
      ORDER BY packageinstance.created DESC", array( $locationId ) );
  </code></pre>
  
  <p>AngularJS within ng-repeat="doc in documents"</p>
  
  <pre><code>&lt;td data-title="'Date'" 
      sortable="'created'" 
      ng-bind="(doc.created|date:mediumDate)"&gt;&lt;/td&gt; // attempt one
  
  &lt;td data-title="'Date'" 
      sortable="'date'" 
      ng-bind="(doc.date|date:mediumDate)"&gt;&lt;/td&gt; // attempt two
  </code></pre>
  
  <p>With either of these formats the sorting isn't working as it sorts based on a string.  Is there anyway to convert the date to something that Angular can filter, but sorts based on date value, that only requires changes in SQL statement?  If not what do I need to do to get the sort to work?</p>