What am I doing wrong in the 'andWhere' part of this query? I've tried a variety of different ways of doing it but nothing seems to work... It just seems to be ignored. Does anyone know the proper way I should be doing it?

foreach($entryIds as $entryId) {
    $data[] = craft()->db->createCommand()
            'elementId' => $entryId
    ->andWhere('dateCreated > 2017-02-11')

return array($data);
  • 2
    Try: ->andWhere('dateCreated > "2017-02-11"')
    – Brad Bell
    Feb 17, 2017 at 17:20

1 Answer 1


The syntax for comparing a date should be:

->andWhere('dateCreated > "2017-02-11"')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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