Title: dates not sorting properly
Last modified: February 6, 2020

---

# dates not sorting properly

 *  Resolved [baseballtimeintx](https://wordpress.org/support/users/baseballtimeintx/)
 * (@baseballtimeintx)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/dates-not-sorting-properly/)
 * The date columns sort by numerical value rather than by date. Have tried adjusting
   settings and using different date formats.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdates-not-sorting-properly%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/dates-not-sorting-properly/#post-12407449)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * It seems that the sorting algorithm could not detect that the DOB column has 
   dates in it. You could try manually setting the type. For that, please add this
   to the “Custom Commands” text field on the table’s “Edit” screen:
 *     ```
       "columnDefs": [ { "type": "date", "targets": [ 4 ] } ]
       ```
   
 * Note that the other columns will still not sort correctly, as these are not “
   full” dates. To sort those by month/year, the best chance should be an approach
   like [https://wordpress.org/support/topic/date-order-6/](https://wordpress.org/support/topic/date-order-6/)
 * Regards,
    Tobias
 *  Thread Starter [baseballtimeintx](https://wordpress.org/support/users/baseballtimeintx/)
 * (@baseballtimeintx)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/dates-not-sorting-properly/#post-12407486)
 * Thank you! I really appreciate the help and the quick response.
 *  Thread Starter [baseballtimeintx](https://wordpress.org/support/users/baseballtimeintx/)
 * (@baseballtimeintx)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/dates-not-sorting-properly/#post-12407810)
 * One more question. If I add a hidden column after the “Add to 40” column with
   complete dates and use that column to sort, would this be the correct custom 
   command?
 * “columnDefs”:[{“orderData”:[6], “targets”:[5]}, {“visible”:false,”targets”:[6]}]
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/dates-not-sorting-properly/#post-12409487)
 * Hi,
 * no, from what I count, you’d need to use 6 and 7 in the code here. Counting the
   columns starts from 0 for the first column on the left.
 * In addition, you’d need to merge the two `"columnDefs"` commands:
 *     ```
       "columnDefs": [ { "type": "date", "targets": [ 4 ] } ], { "orderData": [ 7 ], "targets": [ 6 ] }, { "visible": false, "targets": [ 7 ]  } ]
       ```
   
 * Regards,
    Tobias
    -  This reply was modified 6 years, 4 months ago by [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘dates not sorting properly’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

## Tags

 * [dates](https://wordpress.org/support/topic-tag/dates/)

 * 4 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/dates-not-sorting-properly/#post-12409487)
 * Status: resolved