Sort column with Date day/month/year

Sort column with Date day/month/year

fernandonaimfernandonaim Posts: 9Questions: 0Answers: 0
edited June 2013 in General
Sorting column with date format: dd/mm/yyyy
I've tried several ways but without success.

Can anyone help me?

If you want you can answer in Portuguese!

Replies

  • fernandonaimfernandonaim Posts: 9Questions: 0Answers: 0
    resolved!

    [code]

    jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function(a,b) {
    var ukDatea = a.split('/');
    var ukDateb = b.split('/');

    var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
    var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    };

    jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a,b) {
    var ukDatea = a.split('/');
    var ukDateb = b.split('/');

    var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
    var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

    return ((x < y) ? 1 : ((x > y) ? -1 : 0));
    };


    [/code]
This discussion has been closed.