Answers.Body: <p>Try something like:</p>
  
  <pre><code>{% set firstDayOfMonth = year ~ "-" ~ month ~ "-01" %}
  {% set daysInThisMonth = firstDayOfMonth|date('t') %}
  {% set lastDayOfMonth  = year ~ "-" ~ month ~ "-" ~ daysInThisMonth %}
  
  {% set thisMonthsOrders = craft.commerce.orders.dateOrdered('and', '&gt;= ' ~ firstDayOfMonth, '&lt;= ' ~ lastDayOfMonth) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-01T21:33:58.977Z
Answers.Text: @YuriSalimovskiy this won't return elements for the last day of the month. You need to add 23:59 as a time to `lastDayOfMonth` or use `date_modify('first day next month')` instead.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-02T08:55:01.023Z
Answers.Text: My dates are provided with GET variable, so that's not a problem. My problem was solved with 'and' keyword
Answers.UserDisplayName: Yuri Salimovskiy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-01T08:13:27.477Z
Answers.LastActivityDate: 2016-07-01T08:13:27.477Z
Answers.UserDisplayName: Luke Holder
Body: <p>I'm having a problem with wrong results when filtering order by date.</p>
  
  <p>I use this code:</p>
  
  <pre><code>{% set orders = craft.commerce.orders.dateOrdered(' &gt;= 2016-07-01 00:00:00').dateOrdered(' &lt;= 2016-07-01 23:59:59').find() %}
  </code></pre>
  
  <p>The last order has been placed on 2016-06-29, and there has been no orders placed on 2016-07-01, so I would expect order to have no results. However it just lists all orders in the system.</p>
  
  <p>If I change the date to 2016-06-10, the result is empty - as expected.</p>
  
  <p>Is this bug in Craft / Craft Commerce, or do I miss something?</p>
  
  <p>How do I make sure I get no results, if there have been no orders on this date?</p>
  
Tags: <elementcriteriamodel><plugin-craftcommerce>
Title: Filtering orders by date bring wrong results
ThreadText: # Filtering orders by date bring wrong results
  
  (Asked by: username_0 on 2016-07-01)
  
  I'm having a problem with wrong results when filtering order by date.
  
  I use this code:
  
  ```
  {% set orders = craft.commerce.orders.dateOrdered(' >= 2016-07-01 00:00:00').dateOrdered(' <= 2016-07-01 23:59:59').find() %}
  
  ```
  
  The last order has been placed on 2016-06-29, and there has been no orders placed on 2016-07-01, so I would expect order to have no results. However it just lists all orders in the system.
  
  If I change the date to 2016-06-10, the result is empty - as expected.
  
  Is this bug in Craft / Craft Commerce, or do I miss something?
  
  How do I make sure I get no results, if there have been no orders on this date?
  
  **Tags:** elementcriteriamodel, plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-07-01. Score: 1 | Accepted answer
  
  Try something like:
  
  ```
  {% set firstDayOfMonth = year ~ "-" ~ month ~ "-01" %}
  {% set daysInThisMonth = firstDayOfMonth|date('t') %}
  {% set lastDayOfMonth  = year ~ "-" ~ month ~ "-" ~ daysInThisMonth %}
  
  {% set thisMonthsOrders = craft.commerce.orders.dateOrdered('and', '>= ' ~ firstDayOfMonth, '<= ' ~ lastDayOfMonth) %}
  
  ```
  
  > **Comments:**
  > **username_2**: @username_0 this won't return elements for the last day of the month. You need to add 23:59 as a time to `lastDayOfMonth` or use `date_modify('first day next month')` instead.  
  > **username_0**: My dates are provided with GET variable, so that's not a problem. My problem was solved with 'and' keyword  
  
  ---
  
  