<p>This should do what you're looking for:</p>

<pre><code>{% set event = craft.entries({
    section: 'events',
    startDate: 'and, &gt;= ' ~ formYear ~ ', &lt; ' ~ (formYear + 1)
}).one() %}
</code></pre>

CC BY-SA 4.0
2019-03-30T23:08:33.053Z
2019-03-30T23:08:33.053Z
Brad Bell
<p>I am trying to get all entries posted from 2018 and only 2018. All the other methods I've seen are for from a specific date or between two dates. Is there a simple way to get all posts from 2018 without having to specify <code>get all entries between 1 January 2018 and 31 December 2018</code>?</p>

<p>The markup below is where I have got to, but this is getting all entries from 2018 onwards. But when I change the <code>&gt;=</code> parameter to <code>==</code> it appears to break it.</p>

<pre><code>{% set event = craft.entries.section('events').startDate('&gt;=' ~ formYear).one() %}
</code></pre>

CC BY-SA 4.0
2019-03-29T19:00:06.883Z
Did you [look a this guide](https://craftcms.com/guides/creating-an-archive-page-for-entries#yearly-archive-pages)?
Oli
<entries><datetime>
How to get all entries posted within a specific year?
# How to get all entries posted within a specific year?

(Asked by: username_0 on 2019-03-28)

I am trying to get all entries posted from 2018 and only 2018. All the other methods I've seen are for from a specific date or between two dates. Is there a simple way to get all posts from 2018 without having to specify get all entries between 1 January 2018 and 31 December 2018?
The markup below is where I have got to, but this is getting all entries from 2018 onwards. But when I change the >= parameter to == it appears to break it.
{% set event = craft.entries.section('events').startDate('>=' ~ formYear).one() %}

**Tags:** entries, datetime
> **Comments:**
> **username_1**: Did you [look a this guide](https://craftcms.com/guides/creating-an-archive-page-for-entries#yearly-archive-pages)?  

---

## 1 answers

### Answer by username_2 on 2019-03-30. Score: 2 | Accepted answer

This should do what you're looking for:
{% set event = craft.entries({
    section: 'events',
    startDate: 'and, >= ' ~ formYear ~ ', < ' ~ (formYear + 1)
}).one() %}


---

