Answers.Body: <p>I wonder if you're getting caught out by querying a specific time of day. I think if you don't include the time it would presume '00:00'. What you want is to find any entries with the <code>customDateField</code> value between midnight and 23:59.</p>
  
  <pre><code>{% set myDateString = '2016-04-01' %}
  {% set myDateStart = myDateString | date_modify('00:00') | date('Y-m-d H:i') %}
  {% set myDateEnd = myDateString | date_modify('23:59')  | date('Y-m-d H:i') %}
  
  {% set entries = craft.entries.section('orders').customDateField('and', '&gt;= ' ~ myDateStart, '&lt;= ' ~ myDateEnd) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:13:59.163Z
Answers.Text: there between is not necessary
Answers.UserDisplayName: Vitaliy  Badalov
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-08T00:39:50.093Z
Answers.Text: Although this code is also useful, thank you!
Answers.UserDisplayName: Vitaliy  Badalov
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T10:32:07.517Z
Answers.LastActivityDate: 2016-04-07T10:32:07.517Z
Answers.UserDisplayName: Jamie Pittock
Answers.Body: <p>You don't need any extra php code to do that.</p>
  
  <p>The search function probably does the job for you.</p>
  
  <pre><code>{% set entries = craft.entries.section('orders').search('2016-04-14') %}
  {% for entry in entries %}
    &lt;h1&gt;{{entry.title}} - {{entry.customDateField}}&lt;/h1&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:16:13.893Z
Answers.Text: php for the need to place the code in the element api plugin
Answers.UserDisplayName: Vitaliy  Badalov
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T06:33:28.147Z
Answers.LastActivityDate: 2016-04-07T08:49:11.117Z
Answers.LastEditDate: 2016-04-07T08:49:11.117Z
Answers.UserDisplayName: Marco Schuler
Body: <p>I want to get only entries with a specific date. I created a date field <code>customDateField</code>. It has the following code:</p>
  
  <pre><code>{% set entries = craft.entries.section('orders').customDateField('2016-04-14') %}
  </code></pre>
  
  <p>but this not work. How it will look in php?</p>
  
  <p>In element api plugin i was code:</p>
  
  <pre><code>'endpoints' =&gt; [
      'orders.json' =&gt; [
          'elementType' =&gt; 'Entry',
          'criteria' =&gt; [
              'section' =&gt; 'orders',
              'date' =&gt; '&gt;='.craft()-&gt;request-&gt;getPost('date')
          ],
          'transformer' =&gt; function(EntryModel $entry) {
              return [
                  'id' =&gt; $entry-&gt;id,
              ];
          },
      ],
  ]
  </code></pre>
  
  <p>but it only shows a larger date of entries, need to write <code>'date-&gt;format("Y-m-d")'</code></p>
  
Tags: <plugin-development><elementcriteriamodel><datetime><plugin-elementapi>
Title: Criteria entries by date field
ThreadText: # Criteria entries by date field
  
  (Asked by: username_0 on 2016-04-07)
  
  I want to get only entries with a specific date. I created a date field `customDateField`. It has the following code:
  
  ```
  {% set entries = craft.entries.section('orders').customDateField('2016-04-14') %}
  
  ```
  
  but this not work. How it will look in php?
  
  In element api plugin i was code:
  
  ```
  'endpoints' => [
      'orders.json' => [
          'elementType' => 'Entry',
          'criteria' => [
              'section' => 'orders',
              'date' => '>='.craft()->request->getPost('date')
          ],
          'transformer' => function(EntryModel $entry) {
              return [
                  'id' => $entry->id,
              ];
          },
      ],
  ]
  
  ```
  
  but it only shows a larger date of entries, need to write `'date->format("Y-m-d")'`
  
  **Tags:** plugin-development, elementcriteriamodel, datetime, plugin-elementapi
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-04-07. Score: 2
  
  I wonder if you're getting caught out by querying a specific time of day. I think if you don't include the time it would presume '00:00'. What you want is to find any entries with the `customDateField` value between midnight and 23:59.
  
  ```
  {% set myDateString = '2016-04-01' %}
  {% set myDateStart = myDateString | date_modify('00:00') | date('Y-m-d H:i') %}
  {% set myDateEnd = myDateString | date_modify('23:59')  | date('Y-m-d H:i') %}
  
  {% set entries = craft.entries.section('orders').customDateField('and', '>= ' ~ myDateStart, '<= ' ~ myDateEnd) %}
  
  ```
  
  > **Comments:**
  > **username_0**: there between is not necessary  
  > **username_0**: Although this code is also useful, thank you!  
  
  ---
  
  ### Answer by username_2 on 2016-04-07. Score: 1
  
  You don't need any extra php code to do that.
  
  The search function probably does the job for you.
  
  ```
  {% set entries = craft.entries.section('orders').search('2016-04-14') %}
  {% for entry in entries %}
    <h1>{{entry.title}} - {{entry.customDateField}}</h1>
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: php for the need to place the code in the element api plugin  
  
  ---
  
  