Date in MM/dd/yyyy format not sorting properly
Date in MM/dd/yyyy format not sorting properly

Link to test case: https://live.datatables.net/mutizifa/1/
Error messages shown: None
Description of problem: Sorting appears to sort by month first, not year then month then day then time.
I've linked a test case where this is shown. I've tried using the method from Ording Formatted Dates (Luxon) but not helping resolve the issue.
This question has an accepted answers - jump to answer
Answers
Is some of the example data, but you are defining:
which doesn't match since there is no
am/pm
in the data.Using:
Allows it to work as expected: https://live.datatables.net/mutizifa/2/edit .
Allan
@allan I can see where this fixes the issue in the test case. I even rolled back from the nightly to my current verions I am using and it works as well.
However, when I apply the same datatable.dateTime.js in my local project and add in the DataTable.datetime('MM/dd/yyyy HH:mm:ss'); it still did not work.
I even pulled in the entire test case to my local to ensure I had the libraries and settings correctly applied; this did work as it does in the test case. So, not a library issue or application issue.
I know it is doubtful, but would this be any different when making an ajax call?
I realize the order would be set in my query, but the actual sorting by datetime is not working under this condition.
Here's the setup (I did not include the preHxhr.dt, xhr.dt, layout, and other options to try and keep it limited):
You have enabled server side processing with
serverSide: true,
. All sorting, searching and paging functions are performed by the server script. TheDataTable.datetime( .. )
definitions work only with client side processing. The server script will need debugged and fixed to sort the datetime field correctly.Can you post the relevant portion of the server script for the query?
What is the field definition for the datetime field?
Kevin
@kthorngren Thank you for pointing that out. It's just a datetime field in SQL. But my mistake was trying to perform a OrderByDynamic function after the table was returned such as this:
That would sort fine if it was not a datetime column.
I ended up just appending my query with:
This works fine now.