Answers.Body: <p>It seems that <code>before</code> and <code>after()</code> don't work with the year as an <code>int</code>, if instead of '2018', you use '2018-01-01', your code works again. <a href="https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#parameters" rel="nofollow noreferrer">Check this</a>.</p>
  
  <p>Basically, use a <a href="http://php.net/class.datetime" rel="nofollow noreferrer">DateTime</a> object
  :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:14:57.347Z
Answers.Text: Actually, this doesn't seem right. Using '2018' use to work...
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:23:55.090Z
Answers.Text: I'll give this a try, but I should point out that this worked all the way up until my most recent Craft update.
Answers.UserDisplayName: Ernie Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:24:36.657Z
Answers.Text: Yes, hence my comment above... might be a little bug :)
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:37:47.133Z
Answers.Text: I'll give this thread a shout over at Github.
Answers.UserDisplayName: Ernie Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T17:56:06.357Z
Answers.LastActivityDate: 2019-02-01T17:56:06.357Z
Answers.UserDisplayName: Oli
Body: <p><em><strong>Edit:</strong> This is confirmed as a bug in Craft, that will be fixed in its next release. If you're running into this, please see the temporary fix over at GitHub: <a href="https://github.com/craftcms/cms/issues/3772" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/3772</a></em></p>
  
  <p><em>I'm leaving up the original post for posterity.</em></p>
  
  <p>--</p>
  
  <p>I'm running into an issue with the recent update for Craft 3.1. I've not changed any of my code on the archive pages, but the list of entries on my archive pages stopped showing up.</p>
  
  <p>Here is the code I use to set up the date ordering.</p>
  
  <pre><code>{% set firstEntryEver = craft.entries.section('posts').orderBy('postDate asc').one() %}
  {% set lastEntryEver = craft.entries.section('posts').orderBy('postDate desc').one() %}
  {% if craft.app.request.getSegment(2) is null %}
      {% set year = 2018 %}
  {% else %}
      {% set year = craft.app.request.getSegment(2) %}
  {% endif %}
  {% set archiveBlurbs = craft.entries.section('archives').type('yearBlurb').archiveYear(year) %}
  {% set monthBlurbs = craft.entries.section('archives').type('monthBlurb').archiveYear(year) %}
  {% set entriesInYear = craft.entries.section('posts').limit(null).after(year).before(year+1).all() %}
  </code></pre>
  
  <p>And the call I use is <code>{% for month, entriesInMonth in entriesInYear | group("postDate|date('F')") %}</code>. The content is then separated by month over a single year.</p>
  
  <p>The logic I use here <a href="https://craftcms.com/guides/creating-an-archive-page-for-entries" rel="nofollow noreferrer">generally follows the official docs</a> with some light modifications. I find that the content for all years shows up if I remove the <code>before</code>.</p>
  
  <p>Any idea what might be at play here?</p>
  
Tags: <craft3><datetime><postdate><archives>
Title: Archive page date logic stopped working
ThreadText: # Archive page date logic stopped working
  
  (Asked by: username_0 on 2019-02-01)
  
  ***Edit:** This is confirmed as a bug in Craft, that will be fixed in its next release. If you're running into this, please see the temporary fix over at GitHub: <https://github.com/craftcms/cms/issues/3772>*
  
  *I'm leaving up the original post for posterity.*
  
  --
  
  I'm running into an issue with the recent update for Craft 3.1. I've not changed any of my code on the archive pages, but the list of entries on my archive pages stopped showing up.
  
  Here is the code I use to set up the date ordering.
  
  ```
  {% set firstEntryEver = craft.entries.section('posts').orderBy('postDate asc').one() %}
  {% set lastEntryEver = craft.entries.section('posts').orderBy('postDate desc').one() %}
  {% if craft.app.request.getSegment(2) is null %}
      {% set year = 2018 %}
  {% else %}
      {% set year = craft.app.request.getSegment(2) %}
  {% endif %}
  {% set archiveBlurbs = craft.entries.section('archives').type('yearBlurb').archiveYear(year) %}
  {% set monthBlurbs = craft.entries.section('archives').type('monthBlurb').archiveYear(year) %}
  {% set entriesInYear = craft.entries.section('posts').limit(null).after(year).before(year+1).all() %}
  
  ```
  
  And the call I use is `{% for month, entriesInMonth in entriesInYear | group("postDate|date('F')") %}`. The content is then separated by month over a single year.
  
  The logic I use here [generally follows the official docs](https://craftcms.com/guides/creating-an-archive-page-for-entries) with some light modifications. I find that the content for all years shows up if I remove the `before`.
  
  Any idea what might be at play here?
  
  **Tags:** craft3, datetime, postdate, archives
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-02-01. Score: 1
  
  It seems that `before` and `after()` don't work with the year as an `int`, if instead of '2018', you use '2018-01-01', your code works again. [Check this](https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#parameters).
  
  Basically, use a [DateTime](http://php.net/class.datetime) object
  :)
  
  > **Comments:**
  > **username_1**: Actually, this doesn't seem right. Using '2018' use to work...  
  > **username_0**: I'll give this a try, but I should point out that this worked all the way up until my most recent Craft update.  
  > **username_1**: Yes, hence my comment above... might be a little bug :)  
  > **username_0**: I'll give this thread a shout over at Github.  
  
  ---
  
  