Selecting date NOT NULL records between a specific range with Propel
- by Jon Winstanley
Using Propel I would like to find records which have a date field which is not null and also between a specific range.
However, Propel seems to overwrite the criteria with the NOTNULL criteria.
Is it possible to do this?
//create the date ranges
$start_date = mktime(0, 0, 0, date("m") , date("d")+$start, date("Y"));
$end_date = mktime(0, 0, 0, date("m") , date("d")+$end, date("Y"));
//add the start of the range
$c1 = $c->getNewCriterion(TaskPeer::DUE_DATE, null);
$c1->addAnd($c->getNewCriterion(TaskPeer::DUE_DATE, $end_date, Criteria::LESS_EQUAL));
$c->add($c1);
//add the end of the range
$c2 = $c->getNewCriterion(TaskPeer::DUE_DATE, null);
$c2->addAnd($c->getNewCriterion(TaskPeer::DUE_DATE, $start_date, Criteria::GREATER_EQUAL));
$c->add($c2);
//remove the null entries
$c3 = $c->getNewCriterion(TaskPeer::DUE_DATE, null);
$c3->addAnd($c->getNewCriterion(TaskPeer::DUE_DATE, null, Criteria::ISNULL));
$c->add($c3);