Return a list of form submissions within a date range

Permalink
I would like to get a collection of form results stored within the new express form type for the last 24 hours.

Can anyone help point me in the right direction?

TheRealSean
 
TheRealSean replied on at Permalink Best Answer Reply
TheRealSean
I had some help from Korvin and arrived at the following which gets an entity list and then runs a custom search on it returning a list which allows it to be passed to the CSV writer.

$entityHandle = 'register';
$em = \Database::connection()->createEntityManager();
$entity = \Express::getObjectByHandle($entityHandle);
if ($entity) {
    $date = new \DateTime();
    $date->modify('-24 hour');
    $search = new \Concrete\Controller\Search\Express\Entries();
    $search->search($entity);
    $itemList = $search->getListObject();
    $list = new \Concrete\Core\Express\EntryList($entity);
    $query = $list->getQueryObject();
    $query->where('e.exEntryDateCreated > :date');
    $query->setParameter('date', $date->format('Y-m-d H:i:s'));
    $writer = new \Concrete\Core\Express\Export\EntryList\CsvWriter(\League\Csv\Writer::createFromPath('php://output', 'w'), new \Concrete\Core\Localization\Service\Date());
    $writer->insertHeaders($entity);