Title: date format and sorting
Last modified: October 24, 2017

---

# date format and sorting

 *  Resolved [tightywritey](https://wordpress.org/support/users/tightywritey/)
 * (@tightywritey)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/)
 * hi,
    I think I’ve read all the previous posts about this and am still stuck. 
   I have a column of date values that I imported that are like YYYY/MMM/DD, for
   example, 2017/FEB/09. I can easily change the “/” to something else or possibly
   swap the order, say, 09FEB2017 but would like to avoid all numbers as that’s 
   not always clear to a reader from somewhere (EU or US) …is 1.12.2017 January 
   12th? or Dec. 1st? Having the text month value is clear. Is there some way to
   sort this YYYY/MMM/DD (or DD/MMM/YYYY or MMM/DD/YYYY etc.)? Is it possible to
   specify the format for the imported date, so whatever sort algorithm there is
   can chunk it correctly and sort? Would be super nice.
 * I saw this but don’t really understand how I’d use it:
    [https://datatables.net/blog/2014-12-18](https://datatables.net/blog/2014-12-18)
   It seems tantalizingly easy to use but also not. You have to load moment.js and
   somehow get a reference to the table to be able to do the moment( ‘YYYY/MMM/DD’)
   function on it.
 * I tried using
    “columnDefs”: [ { “type”: “date”, “targets”: [ 2 ] } ] but it 
   not only didn’t work it seemed to stop the sorting from happening altogether.

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9618275)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * Unfortunately, using that moment.js library is not yet possible with DataTables
   within TablePress, due to how such plugins are loaded. I might add support for
   it in the future, but cannot guarantee it at this time.
 * Your best chance is probably to use the approach from [https://wordpress.org/support/topic/date-order-6/](https://wordpress.org/support/topic/date-order-6/)
   which deals with a very similar scenario.
 * Regards,
    Tobias
 *  Thread Starter [tightywritey](https://wordpress.org/support/users/tightywritey/)
 * (@tightywritey)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9621282)
 * hi Tobias,
    Thanks for your really quick reply! That’s nice to get a fast response
   when one is frustrated and stuck. I got it to work like you suggested, after 
   some hours of struggle, mostly with my database. My table data comes from a database
   so I modified my SQL query to generate a new column with a date in MM/DD/YYYY
   format (I tried YYYY/MM/DD first as it was less work for me but apparently that
   format is not automatically recognized by TablePress/DataTables). Before hiding
   the extra MM/DD/YYYY formatted column, which I did not want the user to see, 
   I clicked on it’s sort header and it didn’t work–until I added the data type 
   in the Custom Commands field. But, I also had to add the sorting-on-another-column
   command to the Custom Commands field. I managed to figure out how to add both
   and the final command is: “columnDefs”: [ { “type”: “date”, “targets”: [ 2 ] },{“
   orderData”: [ 2 ], “targets”: [ 1 ] } ]
 * So column 1 is the “bad date” column I want to click-sort on and column 2 is 
   the extra MM/DD/YYYY column hidden by CSS in PluginOptions:
    .tablepress .column-
   3 { display: none; }
 * (currently I only have one table so no table number on the tablepress class)
 * I just thought I’d add some details here for anyone else who might have a similar
   problem.
 * p.s. any chance you can recommend a table plugin where I can edit and add/delete
   rows?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9622459)
 * Hi,
 * good to hear that you found a solution for this now 🙂
 * I’m not sure what you mean with the last question. You can edit and add/delete
   rows in TablePress. Or do you mean on the frontend?
 * Regards,
    Tobias
 *  Thread Starter [tightywritey](https://wordpress.org/support/users/tightywritey/)
 * (@tightywritey)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9623168)
 * yes, I want to have some kind of user-editable table that gets saved to the db.
   I also would like to be able to export the table data in .csv or some parseable
   format.
 * I see this plugin, [https://wordpress.org/plugins/wp-db-table-editor](https://wordpress.org/plugins/wp-db-table-editor),
   but don’t know if it’s any good and since you’re a table guru I thought you might
   be able to recommend something.
    There’s also [https://wpdatatables.com](https://wpdatatables.com)
   but it’s $44 and a bit overkill.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9623923)
 * Hi,
 * ah, I see. No sorry, I’m not aware of table plugins that allow frontend data 
   entry 🙁 Sorry.
 * Regards,
    Tobias
 *  Thread Starter [tightywritey](https://wordpress.org/support/users/tightywritey/)
 * (@tightywritey)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9624237)
 * ok, thanks anyway & for the sort fix.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9624285)
 * Hi,
 * no problem! Always happy to help!
 * Best wishes,
    Tobias

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

The topic ‘date format and sorting’ 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/)

 * 7 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/date-format-and-sorting-3/#post-9624285)
 * Status: resolved