Add date range filters to ModelAdmin

setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true);
$dateField = new DateField("q[ToDate]", "To Date");
// Get the DateField portion of the DatetimeField and
// Explicitly set the desired date format and show a date picker
$dateField->setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true);
return $context;
public function getList() {
$list = parent::getList();
$params = $this->request->requestVar('q'); // use this to access search parameters
if(isset($params['FromDate']) && $params['FromDate']) {
$list = $list->exclude('Created:LessThan', $params['FromDate']);
if(isset($params['ToDate']) && $params['ToDate']) {
//split UK date into day month year variables
list($day,$month,$year) = sscanf($params['ToDate'], "%d/%d/%d");
//date functions expect US date format, create new date object
$date = new Datetime("$month/$day/$year");
//create interval of Plus 1 Day (P1D)
$interval = new DateInterval('P1D');
//add interval to the date
//use the new date value as the GreaterThan exclusion filter
$list = $list->filter('Created:LessThan', date_format($date, 'd/m/Y'));
return $list;