Title: Sorting dates that include different years
Last modified: August 21, 2016

---

# Sorting dates that include different years

 *  Resolved [swedishparker](https://wordpress.org/support/users/swedishparker/)
 * (@swedishparker)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/)
 * Hey Tobias, I’m having trouble sorting date ranges that include different years.
 * I’m using the date format mm/dd/yyyy and for example, the 04/dd/2014 rows are
   sorted ahead of the 05/dd/2013 rows.
 * If you go to this page and click on the Date column header, you’ll see what I
   mean:
 * supracer.com/calendar/
 * Any ideas?
 * Thank you!
    – Chris
 * [http://wordpress.org/extend/plugins/tablepress/](http://wordpress.org/extend/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/#post-3750580)
 * Hi Chris,
 * thanks for your post, and sorry for the trouble.
 * I’m not really sure why this happens, but it might be necessary to tell the DataTables
   JavaScript library (that TablePress uses for the sorting) to explicitely handle
   the first column as dates. To do that, please add this to the “Custom Commands”
   textfield on the “Edit” screen of the table:
 *     ```
       "aoColumnDefs": [ { "sType": "date", "aTargets": [ 0 ] } ]
       ```
   
 * Regards,
    Tobias
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/#post-3750613)
 * Hi,
 * I just found another possible reason for this: In the “Date” column, a few cells
   have HTML in them, like `<a name="May">`. Most likely this breaks the date sorting,
   so I recommend that you remove that, and maybe move those to a column that already
   does string sorting (because those will not break then).
 * Regards,
    Tobias
 *  Thread Starter [swedishparker](https://wordpress.org/support/users/swedishparker/)
 * (@swedishparker)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/#post-3750616)
 * Perfect!
 * Thank you very much for your help (and for replying so quickly).
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/#post-3750627)
 * Hi,
 * sure, no problem! You are very welcome!
    (You should now no longer need the “
   Custom Command”.)
 * Best wishes,
    Tobias
 *  [designrushuk](https://wordpress.org/support/users/designrushuk/)
 * (@designrushuk)
 * [13 years ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/#post-3750812)
 * Hey Tobias,
 * I am having issues with the java functionality. I experimented with the col span
   and it broken the sorting. I knew this was the case, but now, having removed 
   the colspan, the java has not returned and any new tables I create will not allow
   me to use any Java functionality.
 * I have tried removing the plugin and re installing but the database just returns
   the same forms etc.
 * Any ideas how i can return the java functionality
 * Thanks
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/#post-3750818)
 * Hi,
 * as you have asked the same at [http://wordpress.org/support/topic/sort-functionality-issues](http://wordpress.org/support/topic/sort-functionality-issues)
   I have answered over there.
 * Regards,
    Tobias

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

The topic ‘Sorting dates that include different years’ 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/)

 * 6 replies
 * 3 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/sorting-dates-that-include-different-years/#post-3750818)
 * Status: resolved