Sort datatable by month name column

I want to sort datatable by month name and the month names are in french how would I do that . I have searched alot but didn't get any result. Any will be of great use . Thank you

Answers


You have searched? I dont think so

ORDER BY FIELD(MONTH,'January','February','March',...)


SELECT leave_balance.balance, MonthName(leave_balance.date_added) AS month 
FROM leave_balance WHERE leave_balance.staff_id_staff = $iid 
GROUP BY month,  leave_balance.leave_type_id_leave_type 
HAVING leave_balance.leave_type_id_leave_type = $leaveBalTypID 
ORDER BY FIELD(MONTH,'January','February','March',...,'December');

Duplicate from: MySql - order by monthname

First google result

Datatables, my bad, and still, first result ;)

var monthNames = ["January", "February", "March", 
    "April", "May", "June", 
    "July", "August", "September", 
    "October", "November", "December"];
jQuery.fn.dataTableExt.oSort['month-name-asc'] = function (x, y) {
    var xPos, yPos;
    jQuery.each(monthNames, function (k, v) {
        if (x == v) xPos = k;
        if (y == v) yPos = k
    });
    return ((xPos < yPos) ? -1 : ((xPos > yPos) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['month-name-desc'] = function (x, y) {
    var xPos, yPos;
    jQuery.each(monthNames, function (k, v) {
        if (x == v) xPos = k
        if (y == v) yPos = k
    });
    return ((xPos > yPos) ? -1 : ((xPos < yPos) ? 1 : 0));
};

http://drmsite.blogspot.com/2013/08/datatables-custom-sort-by-month-name.html


Update for Datatables 1.10+

var monthNames = ["January", "February", "March", 
    "April", "May", "June", 
    "July", "August", "September", 
    "October", "November", "December"];

   jQuery.extend(jQuery.fn.dataTableExt.oSort, {
        "month-name-asc": function (a, b) {
            var xPos = 0, yPos = 0;
            $.each(monthNames, function (k, v) {
                if (a == v) xPos = k;
                if (b == v) yPos = k;
            });
            return ((xPos < yPos) ? -1 : ((xPos > yPos) ? 1 : 0));
        },

        "month-name-desc": function (a, b) {
            var xPos = 0, yPos = 0;
            $.each(monthNames, function (k, v) {
                if (a == v) xPos = k;
                if (b == v) yPos = k;
            });
            return ((xPos > yPos) ? -1 : ((xPos < yPos) ? 1 : 0));
        }
    });

Need Your Help

Java - How to find extreme points of cubic spline?

java jfreechart

Is there any ready libraries that can help to find extreme points of cubic spline?

how to validate dynamically generated form containing bootstrap tabs in jquery

javascript jquery html validation

In my project i'm dynamically generating an html form using jquery. Here the page consist of five tabs each having separate previous and next buttons. The tab is designed using bootstrap. Can anyone