How to extend custom date range selection in bootstrape daterangepicker

Viewed 1158

I am using bootstrap daterangepicker plugin, I am facing problem by selecting large range like 3-4 years in custom range. currently it allows custom range within one month only. I tried the minDate and maxDate from other plugin which is also not working here.

And how can I search all time data by clicking all time tab and search it within minDate and maxDate range.

jsFiddle

 $('.selectrange').daterangepicker({
    showDropdowns: true,
    timePicker: true,
    minDate: [moment().subtract(20,'years'),'inclusive'],
    maxDate: [moment(),'inclusive'],
    ranges: {
       'Today': [moment(), moment()],
       'Last 7 Days': [moment().subtract(6, 'days'), moment()],
       'Last 30 Days': [moment().subtract(29, 'days'), moment()],
       'This Month': [moment().startOf('month'), moment().endOf('month')],
       'All Time':'all-time', // [minDate, maxDate]
    }
});
2 Answers

I think this should do the trick for you:

Add option linkedCalendars: false, for example:

Code:

$('.selectrange').daterangepicker({
    linkedCalendars: false,
    showDropdowns: true,
    timePicker: true,
    minDate: moment().subtract(20, 'years'),
    maxDate: moment(),
    ranges: {
        'Today': [moment(), moment()],
        'Last 7 Days': [moment().subtract(6, 'days'), moment()],
        'Last 30 Days': [moment().subtract(29, 'days'), moment()],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
        'All Time': 'all-time', // [minDate, maxDate]
    }
});

Screenshot:

Date Range Picker

I think you want this right.

'All Time':[moment().subtract(20,'years'), moment()]
Related