Sorting dates in columns

Sorting dates in columns

sjw01sjw01 Posts: 36Questions: 16Answers: 0

I see this:

From what I understand, effectively a date column can only be sorted provided they are displayed as YYYY-MM-DD?

Is that right? The "limited set of dates" link to in the option shows YYYY-MM-DD ... YYYY/MM/DD

Which effectively is just sorting numerically and doesn't really require the field type to be a date? If I put the date into a format that allows sorting numerically, there is no point to defining a column type = date?

As can be seen, - all date columns are displayed DD/MM/YY and don't sort

Am I misinterpreting the doco? Displaying the date as YYYY-MM-DD is really unfriendly and I want to avoid it?


  • xtech_devxtech_dev Posts: 10Questions: 4Answers: 0
  • MSLtdMSLtd Posts: 53Questions: 5Answers: 4

    Hello @sjw01
    When you're using the DataTables date column you are limited to a very finite subset of formatting options, all of which I'm pretty sure, are in the format YYYY-MM-DD.

    If you are wishing to have a user friendly format, I'd recommend using the render attribute of the column declaration in your table initiation, to render an HTML5 Input of type: date (<input type="date" name="inputFieldName">) in the editor and pushing the information around yourself.

    In other news, I've had a play with the example and the date columns sort fine??

  • allanallan Posts: 47,070Questions: 1Answers: 6,629 Site admin

    Have a read over this blog post which goes into full details of date / time sorting in DataTables.


  • sjw01sjw01 Posts: 36Questions: 16Answers: 0

    @MSLtd It would appear that the column is sorted using the rendered data so we're back to square one. The columns definitely don't sort as required.

    @allan thanks, i'll take a look

Sign In or Register to comment.