Answers.Body: <pre><code>'&gt;= ' ~ dateFrom|date('c')
  </code></pre>
  
  <p>is correct to output the DateTime object as a string with the time (and timezone) included. If you don’t use the filter it’s output in the <code>Y-m-d</code> format by default.</p>
  
  <p>So my recommendation would be to double check what <code>dateFrom|date('c')</code> actually outputs and to compare it with the <code>dateOrdered</code> values in the CP or database.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-13T19:39:28.617Z
Answers.Text: Thanks a lot, of course `'>= ' ~ dateFrom|date('c')` works perfectly fine.. I didn't get any output before, because (i think) the database time is UTC and  crafts dates are UTC+2. So I ended up taking the offset into account by doing this:
  `{% set dateFrom = now|date_modify( ((now|date("Z") + 3600)  * (-1)) ~' seconds') %}` and `.dateOrdered( '>= ' ~ dateFrom|date('c'))`
Answers.UserDisplayName: alex_craze
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-14T06:16:36.693Z
Answers.Text: Something isn’t right, you should not need to factor in any timezone differences.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-21T12:53:03.783Z
Answers.Text: sry, for my late reply. there is indeed something odd going on between our DB and craft - but as this behavior only occurs on the dev-environment I am just going to ignore this for now. Anyways, the original question was answered perfectly! thx alot.
Answers.UserDisplayName: alex_craze
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-13T11:31:32.363Z
Answers.LastActivityDate: 2017-10-13T11:31:32.363Z
Answers.UserDisplayName: carlcs
Body: <p>How can I query all completed orders within the last hour? It seems craft is only comparing a date by <code>YYYY-MM-DD</code>.</p>
  
  <p>Following query collects all orders from the same day, as <code>{{dateFrom}}</code> would output <code>2017-10-13</code> and not eg. <code>2017-10-13 11:22:08</code></p>
  
  <pre><code>{% set dateFrom = now|date_modify('-3600 seconds') %}
  {% for order in craft.commerce.orders.dateOrdered( '&gt;= ' ~ dateFrom) %}
    ...
  {% endfor %}
  </code></pre>
  
  <p>adding something like 
  <code>craft.commerce.orders.dateOrdered( '&gt;= ' ~ dateFrom|date('c'))</code> would find any orders at all.</p>
  
Tags: <plugin-craftcommerce><datetime>
Title: query orders by date AND time in craft commerce
ThreadText: # query orders by date AND time in craft commerce
  
  (Asked by: username_0 on 2017-10-13)
  
  How can I query all completed orders within the last hour? It seems craft is only comparing a date by `YYYY-MM-DD`.
  
  Following query collects all orders from the same day, as `{{dateFrom}}` would output `2017-10-13` and not eg. `2017-10-13 11:22:08`
  
  ```
  {% set dateFrom = now|date_modify('-3600 seconds') %}
  {% for order in craft.commerce.orders.dateOrdered( '>= ' ~ dateFrom) %}
    ...
  {% endfor %}
  
  ```
  
  adding something like
  `craft.commerce.orders.dateOrdered( '>= ' ~ dateFrom|date('c'))` would find any orders at all.
  
  **Tags:** plugin-craftcommerce, datetime
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-10-13. Score: 1 | Accepted answer
  
  ```
  '>= ' ~ dateFrom|date('c')
  
  ```
  
  is correct to output the DateTime object as a string with the time (and timezone) included. If you don’t use the filter it’s output in the `Y-m-d` format by default.
  
  So my recommendation would be to double check what `dateFrom|date('c')` actually outputs and to compare it with the `dateOrdered` values in the CP or database.
  
  > **Comments:**
  > **username_0**: Thanks a lot, of course `'>= ' ~ dateFrom|date('c')` works perfectly fine.. I didn't get any output before, because (i think) the database time is UTC and  crafts dates are UTC+2. So I ended up taking the offset into account by doing this: `{% set dateFrom = now|date_modify( ((now|date("Z") + 3600)  * (-1)) ~' seconds') %}` and `.dateOrdered( '>= ' ~ dateFrom|date('c'))`  
  > **username_1**: Something isn’t right, you should not need to factor in any timezone differences.  
  > **username_0**: sry, for my late reply. there is indeed something odd going on between our DB and craft - but as this behavior only occurs on the dev-environment I am just going to ignore this for now. Anyways, the original question was answered perfectly! thx alot.  
  
  ---
  
  