<p>"Live" is determined in part by <code>postDate</code> and <code>expiryDate</code> (in addition to <code>status</code>), so not technically independent, but this may be what you're after. You would still use the technique described in Carlcs' answer, only that the criteria would be searching the entries using the month values passed to your template.</p>

<pre><code>{% if craft.request.param('startMonth') and craft.request.param('endMonth') %}

    {% set startMonth = craft.request.param('startMonth') %}
    {% set endMonth = craft.request.param('endMonth') %}
    {% set startDate = now|date(Y) ~ '-' ~ startMonth %}
    {% set endDate = now|date(Y) ~ '-' ~ endMonth %}

    {% set entries = craft.entries.section('mySectionHandle').postDate('and, &gt;= ' ~ startDate ~ ', &lt;= ' ~ endDate) %}

    {% for entry in entries %}
    ...
    {% endfor %}

{% endif %}
</code></pre>

<p>You could also use <code>.after(starDate).before(endDate)</code> for this.</p>

<p><strong>Update</strong> If you want to get entries that are live during a particular month range (rather than posted during the month range) then you could check for <code>postDate</code> before the selected 'start month' and <code>expiryDate</code> after the selected 'end month'.</p>

<pre><code>{% if craft.request.param('startMonth') and craft.request.param('endMonth') %}

    {% set startMonth = craft.request.param('startMonth') %}
    {% set endMonth = craft.request.param('endMonth') %}
    {% set startDate = now|date(Y) ~ '-' ~ startMonth %}
    {% set endDate = now|date(Y) ~ '-' ~ endMonth %}

    {% set entries = craft.entries.section('mySectionHandle').postDate('&lt;= ' ~ startDate).expiryDate('&gt;= ' ~ endDate) %}

    {% for entry in entries %}
    ...
    {% endfor %}

{% endif %}
</code></pre>

<p>Not tested.</p>

CC BY-SA 3.0
2015-04-06T15:45:38.210Z
Thanks for your quick response. I have tried this before, the problem with this is when i have entry (say: Foo) which is posted on jan with null on expiry date. For instance if i selected march from drop down with start and end date of a month then my Foo jan month entry will not showing Bcz it's post date is set to jan and there no expiry date and same with after and before. In all the above cases we are checking postdate which is not right solution in my case. I'm stuck here.
lokesh
CC BY-SA 3.0
2015-04-06T16:25:30.113Z
I see your problem. I added another example that may work (not sure). However, it doesn't account for entries that are live only for a short time within the  month range. For that you may need to check for a postDate before the endMonth, and expiryDate after the startMonth.
Douglas McDonald
CC BY-SA 3.0
2015-04-21T16:27:15.577Z
Thanks Douglas. Your updated answer works fine with some little modification based on my requirement.
lokesh
CC BY-SA 3.0
2015-04-02T22:17:34.937Z
2016-10-30T21:04:00.120Z
2016-10-30T21:04:00.120Z
Douglas McDonald
<p>For some ElementCriteriaModel parameters it is possible to define a range of possible values (→ <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel#parameter-value-syntax" rel="nofollow">Parameter Value Syntax</a>). In case of your dropdown field you should be able to filter your entries for value between 1 (January) and 3 (March) like so.</p>

<pre><code>{% set entries = craft.entries.myDropdownField('and, &gt;= 1, &lt;= 3') %}
</code></pre>

<p>You could also define a list of values like so.</p>

<pre><code>{% set entries = craft.entries.myDropdownField('or, 1, 2, 3') %}
</code></pre>

CC BY-SA 3.0
2015-04-02T21:41:23.263Z
Thanks for your response. Sorry i didn't explain my question clearly. I'm working on template side. I have form with dropdown and i'm not storing my drop down into database. All months are in select drop-down form. After submission of the form i'm trying to display live entries of that month.
lokesh
CC BY-SA 3.0
2015-04-02T17:06:27.140Z
2015-04-02T17:06:27.140Z
carlcs
<p>I'm trying to show live entries to user by selecting list of months in a dropdown. Some my entries are live for 2 or 3 months. I having trouble in finding right method. I have tried using <strong>after and before</strong> but i think these work based on postdate of an entry. Correct me if i'm wrong. This all in template side.</p>

<templating><datetime>
How to show entries which are live between dates regardless of postdate or expiry dates?
# How to show entries which are live between dates regardless of postdate or expiry dates?

(Asked by: username_0 on 2015-04-02)

I'm trying to show live entries to user by selecting list of months in a dropdown. Some my entries are live for 2 or 3 months. I having trouble in finding right method. I have tried using **after and before** but i think these work based on postdate of an entry. Correct me if i'm wrong. This all in template side.

**Tags:** templating, datetime


---

## 2 answers

### Answer by username_1 on 2015-04-02. Score: 4 | Accepted answer

"Live" is determined in part by postDate and expiryDate (in addition to status), so not technically independent, but this may be what you're after. You would still use the technique described in Carlcs' answer, only that the criteria would be searching the entries using the month values passed to your template.
{% if craft.request.param('startMonth') and craft.request.param('endMonth') %}

    {% set startMonth = craft.request.param('startMonth') %}
    {% set endMonth = craft.request.param('endMonth') %}
    {% set startDate = now|date(Y) ~ '-' ~ startMonth %}
    {% set endDate = now|date(Y) ~ '-' ~ endMonth %}

    {% set entries = craft.entries.section('mySectionHandle').postDate('and, >= ' ~ startDate ~ ', <= ' ~ endDate) %}

    {% for entry in entries %}
    ...
    {% endfor %}

{% endif %}

You could also use .after(starDate).before(endDate) for this.
Update If you want to get entries that are live during a particular month range (rather than posted during the month range) then you could check for postDate before the selected 'start month' and expiryDate after the selected 'end month'.
{% if craft.request.param('startMonth') and craft.request.param('endMonth') %}

    {% set startMonth = craft.request.param('startMonth') %}
    {% set endMonth = craft.request.param('endMonth') %}
    {% set startDate = now|date(Y) ~ '-' ~ startMonth %}
    {% set endDate = now|date(Y) ~ '-' ~ endMonth %}

    {% set entries = craft.entries.section('mySectionHandle').postDate('<= ' ~ startDate).expiryDate('>= ' ~ endDate) %}

    {% for entry in entries %}
    ...
    {% endfor %}

{% endif %}

Not tested.

> **Comments:**
> **username_0**: Thanks for your quick response. I have tried this before, the problem with this is when i have entry (say: Foo) which is posted on jan with null on expiry date. For instance if i selected march from drop down with start and end date of a month then my Foo jan month entry will not showing Bcz it's post date is set to jan and there no expiry date and same with after and before. In all the above cases we are checking postdate which is not right solution in my case. I'm stuck here.  
> **username_1**: I see your problem. I added another example that may work (not sure). However, it doesn't account for entries that are live only for a short time within the  month range. For that you may need to check for a postDate before the endMonth, and expiryDate after the startMonth.  
> **username_0**: Thanks Douglas. Your updated answer works fine with some little modification based on my requirement.  

---

### Answer by username_2 on 2015-04-02. Score: 3

For some ElementCriteriaModel parameters it is possible to define a range of possible values (→ Parameter Value Syntax). In case of your dropdown field you should be able to filter your entries for value between 1 (January) and 3 (March) like so.
{% set entries = craft.entries.myDropdownField('and, >= 1, <= 3') %}

You could also define a list of values like so.
{% set entries = craft.entries.myDropdownField('or, 1, 2, 3') %}

> **Comments:**
> **username_0**: Thanks for your response. Sorry i didn't explain my question clearly. I'm working on template side. I have form with dropdown and i'm not storing my drop down into database. All months are in select drop-down form. After submission of the form i'm trying to display live entries of that month.  

---

