wrong sorting of date column which contains 2 different date formats
wrong sorting of date column which contains 2 different date formats

Hello,
i am trying to sort a table column which contains 2 different date formats but the sorting is wrong.
I have included the 2 date formats from moments.js
$.fn.dataTable.moment( 'DD.MM.YYYY' );
$.fn.dataTable.moment( 'DD.MM.YYYY HH:mm' );
The sorting is executed with this outcome, which is false
If i add to all dates the time to the end or if i remove it, the sorting is correct
Does anyone have a clue about this problem?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
My guess is the Datatable moment.js sorting plugin expects only one format per column. If more than one are found then the column type is set to string. Just a guess though.
One option is to use orthogonal data and for the
sort
andtype
operations drop the time from the date or add00:00
to the dates missing the time. Another option is to create you own sorting plugin.If you need help with either of these options please build a simple test case with an example of your data and what you are trying.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin