<p>The syntax for comparing a date should be:</p>

<pre><code>-&gt;andWhere('dateCreated &gt; "2017-02-11"')
</code></pre>

CC BY-SA 3.0
2017-02-20T18:10:46.330Z
2017-02-20T18:10:46.330Z
Brad Bell
<p>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?</p>

<pre><code>foreach($entryIds as $entryId) {
    $data[] = craft()-&gt;db-&gt;createCommand()
    -&gt;select('*')
    -&gt;from('amforms_content')       
    -&gt;where(array(
            'elementId' =&gt; $entryId
    ))
    -&gt;andWhere('dateCreated &gt; 2017-02-11')
    -&gt;queryAll();
}

return array($data);
</code></pre>

CC BY-SA 3.0
2017-02-17T17:20:16.473Z
Try: `->andWhere('dateCreated > "2017-02-11"')`
Brad Bell
<plugin-development><query>
Can anyone tell me what's wrong with the 'andWhere' part of this query?
# Can anyone tell me what's wrong with the 'andWhere' part of this query?

(Asked by: username_0 on 2017-02-17)

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()
    ->select('*')
    ->from('amforms_content')       
    ->where(array(
            'elementId' => $entryId
    ))
    ->andWhere('dateCreated > 2017-02-11')
    ->queryAll();
}

return array($data);

**Tags:** plugin-development, query

> **Comments:**
> **username_1**: Try: `->andWhere('dateCreated > "2017-02-11"')`  

---

## 1 answers

### Answer by username_1 on 2017-02-20. Score: 2 | Accepted answer

The syntax for comparing a date should be:
->andWhere('dateCreated > "2017-02-11"')


---

