<p>You need to add a <code>fieldId</code> param to make Craft join the content table.</p>

<pre><code>$criteria-&gt;fieldId = $matrixFieldId;
</code></pre>

CC BY-SA 3.0
2016-06-16T14:25:48.530Z
2016-06-16T14:25:48.530Z
carlcs
<p>I am trying to search for specific matrix blocks by date like so: </p>

<pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::MatrixBlock);

$criteria-&gt;ownerId = $entry-&gt;id;

$criteria-&gt;type = 'myMatrixBlockType';

$criteria-&gt;myMatrixBlockDateField = "2016-06-01 04:00:00";

$criteria-&gt;limit = 10;

$blocks = $criteria-&gt;find();
</code></pre>

<p>It seems that no matter what format the date is, all blocks from the matrix field in the entry are returned. Any help is appreciated! </p>

<plugin-development><matrix><datetime>
Search for Matrix Block by Date in plugin
# Search for Matrix Block by Date in plugin

(Asked by: username_0 on 2016-06-16)

I am trying to search for specific matrix blocks by date like so: 
$criteria = craft()->elements->getCriteria(ElementType::MatrixBlock);

$criteria->ownerId = $entry->id;

$criteria->type = 'myMatrixBlockType';

$criteria->myMatrixBlockDateField = "2016-06-01 04:00:00";

$criteria->limit = 10;

$blocks = $criteria->find();

It seems that no matter what format the date is, all blocks from the matrix field in the entry are returned. Any help is appreciated!

**Tags:** plugin-development, matrix, datetime


---

## 1 answers

### Answer by username_1 on 2016-06-16. Score: 1 | Accepted answer

You need to add a fieldId param to make Craft join the content table.
$criteria->fieldId = $matrixFieldId;


---

