Search builder "greater than" search ability?

Search builder "greater than" search ability?

vsekvsek Posts: 30Questions: 17Answers: 0

Hey All, Love search builder. One of my columns happens to be a date/time column. Is it possible to do a < or > type search somehow? Or configure it accordingly?

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    I tried this example and it seems to work:

    Kevin

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    If you're not seeing that with your data, it would suggest that the date isn't being recognised as a date, and is defaulting to a string - so check your values and ensure they're all formatted correctly.

    Colin

  • vsekvsek Posts: 30Questions: 17Answers: 0

    ok, thanks. I might need to a conversion. I bet its coming back as a string instead of a date field

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    edited March 2021

    I wonder if the technique described in this date sorting blog will help to set the type properly for the SearchBuilder to pickup.

    Kevin

  • vsekvsek Posts: 30Questions: 17Answers: 0

    ok question. Below is how I have my columns initialized. Pretty simple. Can I simply format the <TH> to a date/time format or would this all need to be done inside Datatable settings somehow?

    $(function() {
        var dataTableId = '#standard_datatable';
    
        // Data Table
        $(dataTableId).DataTable({   
            dom: 'Bfrtip', 
            pageResize: true,
             buttons: [
                       'copy', 'excel', 'pdf', 'searchBuilder'
                   ],
            ajaxSource : "/cma/contents/screening/load_data",   
    
        });     
    
    
    });
    

    <

    div class="standard-table">

    <

    table class="display" id="standard_datatable">
    <thead>
    <tr>
    <th>Load Status</th>
    <th >Start Time</th>
    <th>Load Duration(Seconds)</th>
    <th>Sender Identifier</th>
    <th>Feed Name</th>
    <th>File Name</th>
    <th>Message Action</th>
    <th>Audit/Load</th>
    <th>Warnings</th>
    <th>Errors</th>
    <th>Total</th>

        </tr>
    </thead>
    
  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Did you look at the date sorting blog I linked?

    I used the technique described and it works.
    http://live.datatables.net/kizofawu/1/edit

    This line is commented out:

    //$.fn.dataTable.moment( 'dddd, MMMM Do, YYYY' );
    

    Try searching by the Start date and you will see the conditions listed won't have options like After. Uncomment that, which matches the date format in the table, re-run the script and you will see range options.

    You will need to use the moment format that matches your date format.

    Kevin

  • vsekvsek Posts: 30Questions: 17Answers: 0

    sweet, thanks

This discussion has been closed.