How do I sort by date in dd.mm.yyyy format.
How do I sort by date in dd.mm.yyyy format.
nadrian
Posts: 5Questions: 1Answers: 0
Hi all,
Really sorry to bother with this noob question but I am really new in this with basic knowledge...
I have this code:
<script type="text/javascript">
$(document).ready(function() {
$('table.display').DataTable({
"order": [[ 0, "desc" ]],
mark: true,
language: {
"sProcessing": "Procesează...",
"sLengthMenu": "Afișează _MENU_ înregistrări pe pagină",
"sZeroRecords": "Nu am găsit nimic - ne pare rău",
"sInfo": "Afișate de la _START_ la _END_ din _TOTAL_ înregistrări",
"sInfoEmpty": "Afișate de la 0 la 0 din 0 înregistrări",
"sInfoFiltered": "(filtrate dintr-un total de _MAX_ înregistrări)",
"sInfoPostFix": "",
"sSearch": "Caută:",
"sUrl": "",
"oPaginate": {
"sFirst": "Prima",
"sPrevious": "Precedenta",
"sNext": "Următoarea",
"sLast": "Ultima"
}
}
});
});
</script>
is it possible to have it sort the date as it should? right now it sorts by number it does not take in consideration that there are dates in dd.mm.yyyy format.
Any help would be really apreciated.
Thank you very much!
Answers
It's likely to be a mismatch of data in that column. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
If your data is already in
dd.mm.yyyy
format, then see this example which shows how DataTables can be configured to operate with any formatted data.Allan
Hi colin,
I am new to this and I have no idea on how to make it work as example, on my webpage it works, but here http://live.datatables.net/zehawori/1/ it does not
Thanks!
Hi Allan,
When I add DataTable.datetime('dd.mm.yyyy'); from that example, the script stops working...
Any ideas why?
Thanks!
Ok so I managed to get it working with DataTable.datetime('dd.mm.yyyy');
added , but it still does not sort accordingly
Any advice please?
Problem solved, it was a mistake in DataTable.datetime('dd.mm.yyyy'); it should have been DD.MM.YYYY instead of small letters.
Thank you!
Thanks for the update. Yes, it looks like you are using Moment.js there, so you would use their parsing tokens.
Allan