<p>I have a list of year from a form field, not in consecutive order. (ES: 2008, 2010, 2012) </p>

<p>I have built an url in this way: <code>q=&amp;year[]=2008&amp;year[]=2010</code> to get all the records of years 2008 and 2010.</p>

<p>I can get the array from url, but was unable to build a query by year on the entries section.</p>

<p>There is a way to query over multiple years?</p>

CC BY-SA 3.0
2016-07-26T23:25:27.540Z
Are you trying to do this from a plugin (PHP) or from a template (Twig)? And are you trying to query a custom date/time field on the entry or by something like postDate?
Brad Bell
CC BY-SA 3.0
2016-07-27T08:24:27.313Z
From a twig template. And I'm query the oistDate.
user5439
CC BY-SA 3.0
2016-07-27T16:59:24.720Z
So from Twig, you want to get all entries where a custom Date/Time field called `oistDate` has year values of 2008 or 2010 or 2012?
Brad Bell
CC BY-SA 3.0
2016-07-27T17:16:19.883Z
No sorry, the field is the publication date of the post postDate
user5439
<querystring>
Query over multiple split years
# Query over multiple split years

(Asked by: username_0 on 2016-07-26)

I have a list of year from a form field, not in consecutive order. (ES: 2008, 2010, 2012)

I have built an url in this way: `q=&year[]=2008&year[]=2010` to get all the records of years 2008 and 2010.

I can get the array from url, but was unable to build a query by year on the entries section.

There is a way to query over multiple years?

**Tags:** querystring

> **Comments:**
> **username_1**: Are you trying to do this from a plugin (PHP) or from a template (Twig)? And are you trying to query a custom date/time field on the entry or by something like postDate?  
> **username_0**: From a twig template. And I'm query the oistDate.  
> **username_1**: So from Twig, you want to get all entries where a custom Date/Time field called `oistDate` has year values of 2008 or 2010 or 2012?  
> **username_0**: No sorry, the field is the publication date of the post postDate  

---

## 0 answers

