Date range between two dates in different columns

Date range between two dates in different columns

guru_das7guru_das7 Posts: 3Questions: 1Answers: 0

I have found the solution for date range filter for two difeerent columns in datatables

$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
var fromDateG = document.getElementById('fromDate').value;
var toDateG = document.getElementById('toDate').value;
fromDateG=fromDateG.substring(6,10) + fromDateG.substring(3,5)+ fromDateG.substring(0,2);
toDateG=toDateG.substring(6,10) + toDateG.substring(3,5)+ toDateG.substring(0,2);

    var datoffromDateG=aData[6].substring(6,10) + aData[6].substring(3,5)+ aData[6].substring(0,2);
    var datoftoDateG=aData[7].substring(6,10) + aData[7].substring(3,5)+ aData[7].substring(0,2);

    if ( fromDateG === "" && toDateG === "" )
    {
        return true;
    }
    else if ( fromDateG <= datoftoDateG && toDateG === "")
    {
        return true;
    }
    else if ( toDateG >= datoftoDateG && fromDateG === "")
    {
        return true;
    }
    else if (fromDateG <= datoffromDateG && toDateG >= datoftoDateG)
    {
        return true;
    }
    return false;
}

);
var table = $('#example').DataTable();

  // Add event listeners to the two range filtering inputs
  $('#fromDate').change( function() { table.draw(); } );
  $('#toDate').change( function() { table.draw(); } );

Replies

  • guru_das7guru_das7 Posts: 3Questions: 1Answers: 0

    guys the code outside also to be included inclusive into document.ready function

This discussion has been closed.