Title: Date column sorting alphabetically
Last modified: April 4, 2018

---

# Date column sorting alphabetically

 *  [ironandsteel](https://wordpress.org/support/users/ironandsteel/)
 * (@ironandsteel)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/)
 * I’m using PDB to display a list of records and it all works great, except for
   date. The first column is a date, and I need to be able to sort by that.
    In 
   PDB->Manage Database Fields, I have set that column to type “Date Field”. When
   I look at the data, I see dates in the format of Month day, year (i.e. March 
   1, 2018). This is the format that they are displayed on the page as well.
 * The problem is that the table sorts this column as though it was text- it doesn’t
   treat it as dates. If I was writing the datatables JS, I know how to tell it 
   the data type for a given column, but how do I get your plugin to set it?
 * Thanks for providing a very handy plugin!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdate-column-sorting-alphabetically%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/#post-10146955)
 * I’m not sure what is happening there. If you have set the field to be a date 
   type field, the data will be stored as Unix timestamps, not date strings. Timestamps
   will sort numerically, then they are converted to human-readable dates when displayed.
 *  Thread Starter [ironandsteel](https://wordpress.org/support/users/ironandsteel/)
 * (@ironandsteel)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/#post-10146985)
 * Curiously, in the back end, PDB->List Participants, I can sort the records by
   the date column and they sort correctly. So, this tells me that this field is
   a time stamp.
 * I think the glitch has to do with the [pdb_list] shortcode.
 * I’ve been looking at the PDB source code and I can’t seem to locate where the
   datatables config javascript is. If I could get to this, I could tweak it.
 * Any hints where I can look?
    Thanks!
    -  This reply was modified 8 years, 1 month ago by [ironandsteel](https://wordpress.org/support/users/ironandsteel/).
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/#post-10147052)
 * This is tested working here, so I’m not sure why you’re getting unexpected results.
 * I don’t, of course, recommend you alter the plugin code. Like most everything
   in WordPress, the database is managed using php, not javascript. If you want 
   to see what database query you’re getting, I suggest you set up debugging: set
   up your php error log, then enable WP_DEBUG. You will then see the database query
   in the log that is used when the list is built, searched or sorted.
 * Also helpful is looking at the database data directly using phpMyAdmin (or similar)
   which is typically available in your hosting control panel.
    -  This reply was modified 8 years, 1 month ago by [xnau webdesign](https://wordpress.org/support/users/xnau/).
 *  Thread Starter [ironandsteel](https://wordpress.org/support/users/ironandsteel/)
 * (@ironandsteel)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/#post-10147142)
 * I recall now that I had a similar problem when I first implemented this 4 years
   ago. It appears from the thread that it was sorting ok on the front end and not
   in the back end. Now I have the opposite problem 🙂
 * [https://wordpress.org/support/topic/what-date-format-will-allow-proper-sorting/?replies=6#post-4952696](https://wordpress.org/support/topic/what-date-format-will-allow-proper-sorting/?replies=6#post-4952696)
 * I realize that the database work is all php, but when the shortcode generates
   the table for the front end, I believe it uses the DataTables jquery plugin to
   manage the user interaction with the table. It seems that code that sets up configuration
   for Datatables is somehow not right in my case.
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/#post-10147196)
 * The javascript just calls a php script to rebuild the list when a search, pagination
   or sort is performed. It doesn’t organize the data in any way.
 * One remote possibility would be page caching…try turning off the “Enable AJAX
   Search Functionality” setting under the advanced tab in Participants Database.
   That will force a page refresh when sorting and if that works, you can be sure
   the problem is caching and not backend code.
 *  Thread Starter [ironandsteel](https://wordpress.org/support/users/ironandsteel/)
 * (@ironandsteel)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/#post-10147243)
 * Roland- I recall now. 4 years ago, I wrote a PDB plugin that used datatables 
   to manage the display since I needed a display with no pagination. I’m trying
   to locate that plugin code now 🙂 Sorry for the confusion.
 * It seems like your normal display code should work for me now. I’m sending you
   an email with my csv file attached, in case you have time to import it and try
   displaying it with your shortcode.
    -  This reply was modified 8 years, 1 month ago by [ironandsteel](https://wordpress.org/support/users/ironandsteel/).
    -  This reply was modified 8 years, 1 month ago by [ironandsteel](https://wordpress.org/support/users/ironandsteel/).

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

The topic ‘Date column sorting alphabetically’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

## Tags

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

 * 6 replies
 * 2 participants
 * Last reply from: [ironandsteel](https://wordpress.org/support/users/ironandsteel/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/date-column-sorting-alphabetically/#post-10147243)
 * Status: not resolved