5

I need to get all the entries that were updated after a certain date, I tried a couple things, but it doesn't seem to work, does anyone know how I can accomplish this?

This seems wrong to me, but it doesn't throw any error, neither does it accomplish what I want.

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = 'affiliates';
$criteria->dateUpdated("> '2015-09-02'");

$query = craft()->elements->buildElementsQuery($criteria);
$queryResults = $query->queryAll();

$affiliates = EntryModel::populateModels($queryResults);

1 Answer 1

6

Your criteria for the date updated was written in the wrong syntax. It should be:

$criteria->dateUpdated = '> 2015-09-02';

You can also simplify the way you query your Element Criteria Model like so:

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = 'affiliates';
$criteria->dateUpdated = '> 2015-09-02';
$affiliates = $criteria->find();

Take a look at the Working with Elements documentation for more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.