How to filter date range in same column?

How to filter date range in same column?

SafrySafry Posts: 3Questions: 1Answers: 0

How to filter date range in same column?

I want to filter the database column with two date ranges, For an example 1-10-2015 - 30-10-2015 should load all the record which has in that date range.

Answers

  • SafrySafry Posts: 3Questions: 1Answers: 0

    tangerine thanks for your reply..

    I need to filter startdate not the age.. how can it be achieved?

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    You can my yadcf filter_type: "range_date" use here an example another example

    know that you must include jquery ui js/css for that

  • radcorpradcorp Posts: 4Questions: 0Answers: 0
    $.fn.dataTable.ext.search.push(
                    function( settings, data, dataIndex ) {
                        var array=[];
                        var today = new Date();
                        var dd = today.getDate();
                        var mm = today.getMonth() + 1;
                        var yyyy = today.getFullYear();
                        
                        if (dd<10)
                        dd = '0'+dd;
                        
                        if (mm<10)
                        mm = '0'+mm;
                        
                                    today = yyyy+'-'+mm+'-'+dd;
                        
                        if ($('#min').val() == '' && $('#max').val() == '') {
                        return true;
                        }
                         if ($('#min').val() != '' || $('#max').val() != '') {
                        var iMin_temp = $('#min').val();
                         if (iMin_temp == '') {
                           iMin_temp = '2009-01-23';
    
                         }
                        
                         var iMax_temp = $('#max').val();
                         if (iMax_temp == '') {
                          iMax_temp = '2015-05-01';
                           array.push(iMax_temp.substr(0,10));
                          
    
                        }
                        
                        var arr_min = iMin_temp.split("-");
                        var arr_max = iMax_temp.split("-");
                        var arr_date = data[1].split("-");
              
                                var iMin = new Date(arr_min[2], arr_min[0], arr_min[1], 0, 0, 0, 0);
                        var iMax = new Date(arr_max[2], arr_max[0], arr_max[1], 0, 0, 0, 0);
                        var iDate = new Date(arr_date[2], arr_date[0], arr_date[1], 0, 0, 0, 0);
                        
                        if ( iMin == "" && iMax == "" )
                        {
                            return true;
                        }
                        else if ( iMin == "" && iDate < iMax )
                        {
                            return true;
                        }
                        else if ( iMin <= iDate && "" == iMax )
                        {
                            return true;
                        }
                        else if ( iMin <= iDate && iDate <= iMax )
                        {
                            return true;
                        }
                                            
                        return false;
                        }
                    }
                );
    
    
      $(document).ready(function(){
        $(function(){
        $( "#min, #max" ).datetimepicker({
             lang: 'es',
             i18n:{
              es:{
                months:[
                'Enero','Febrero','Marzo','Abril','Mayo',
                'Junio','Julio','Agosto','Septiembre','Octubre',
                'Noviembre','Diciembre',],
                dayOfWeek:[
                "Do","Lu","Ma","Mi","Ju","Vi","Sa",]
              }
             },
             format:'Y-m-d',
             // theme:'dark',
           
        });
    });
     
            var oTable=$("#example").DataTable({
                "processing": true,
    "serverSide": true,
    "scrollY":        "200px",
    "scrollCollapse": true,
    "bLengthChange": false, //used to hide the property
        //  "sLengthMenu":false,
    //"aLengthMenu": false,//[[5, 10, 715, -1], [5, 10, 715, "All"]]
            "iDisplayLength": 720,
                "sDom": '<"top">rt<"bottom"ilp><"clear">',
                 "createdRow": function ( row, data, index ) {
                if ( data[2].replace(/[\$,]/g, '') * 1 > 0.2 ) {
                    $('td', row).eq(2).addClass('highlight');
                }
            },
    "ajax":{ "url":"server_processing.php",
     "data": function ( d) {
                    d.push = $('#min').val();
                    //d.push 
                    // d.custom = $('#myInput').val();
                    // etc
                }
                }
            });
    
            /* Add event listeners to the two date-range filtering inputs */
    
        $("#min, #max").keyup( function() { 
            oTable.draw(); 
        } );
            
       
    });
    
  • radcorpradcorp Posts: 4Questions: 0Answers: 0

    espero ayude es con datetimepicker y version datatables 1.10.6

  • radcorpradcorp Posts: 4Questions: 0Answers: 0
    <p>min: <input type="text" id="min"></p>
          <p>max: <input type="text" id="max"></p>
    

    `
    remarco que esto es para el lado del cliente,
    ( it's for "client side")

    `

  • SafrySafry Posts: 3Questions: 1Answers: 0

    thanks for the replies...

  • deepikaguptadeepikagupta Posts: 2Questions: 1Answers: 0

    I have to use database (multiple tables value) and then search for that custom column.. Please reply asap

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    edited February 2016

    You can use my yadcf plugin for that , see showcase samples third column , fourth column , see the various filter types

    p.s bootstrap date picker supported as well, see showcase

    ooopsy, just noticed that I alredy answered it...

  • oscar1925oscar1925 Posts: 1Questions: 0Answers: 0

    daniel_r. can you also add print button?

This discussion has been closed.