Answers.Body: <p>Assuming your date/time field is called <code>dateField</code>, and your entries channel is <code>events</code>.</p>
  
  <p>You want to fetch just the entries that have dates in that month. You can do that like this:</p>
  
  <p>If you know the year and the month, the start of the month is (<code>~</code> is the twig string concatination operator):</p>
  
  <pre><code>{% set startDate = year~'-'~month~'-01' %}
  </code></pre>
  
  <p>And the start of the next month is:</p>
  
  <pre><code>{% set endDate = startDate|date_modify('+1 month')|date('Y-m-d') %}
  </code></pre>
  
  <p>We use twig's <a href="http://twig.sensiolabs.org/doc/2.x/filters/date_modify.html" rel="nofollow noreferrer">date_modify</a> filter to get the start of the next month, and then twig's <a href="http://twig.sensiolabs.org/doc/2.x/filters/date.html" rel="nofollow noreferrer">date</a> filter to convert that to a string.</p>
  
  <p>Now you can fetch the entries for the month. You want ones where the <code>dateField</code> is on or after <code>startDate</code> and before <code>endDate</code>.</p>
  
  <pre><code>{% set monthEvents = craft.entries
    .section('events')
    .dateField(['and', '&gt;= '~startDate, '&lt; '~endDate])
  %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-17T01:53:51.110Z
Answers.LastActivityDate: 2017-02-17T01:53:51.110Z
Answers.UserDisplayName: Marion Newlevant
Body: <p>I am creating a website for not-for-profit organization that help victum of domestic violence. I have a page called Event which display all fund raising events under each month. </p>
  
  <p>I have setup Date/Time field and 12 months tabs and want to know how to display the entries for each month. For example I assign two entries for Feb and when I click on Feb tab, the entries will display.</p>
  
  <p>Here is the sample code I wrote and copied Marion Newlevant's suggestion but when I tested it does not work. Any ideas?</p>
  
  <p>Here is what my html structure to display the entries for each month. </p>
  
  <pre><code>&lt;div class="recent-events2"&gt;
    &lt;ul class="month-tabs"&gt;
      &lt;li{% set startDate = year~'-'~month~'-01' %}&lt;/li&gt;
    &lt;/ul&gt;
  
    &lt;div class="events"&gt;
  
      {% set monthEvents = craft.entries
        .section('events')
        .dateField(['and', '&gt;= '~startDate, '&lt; '~endDate])
      %}
      &lt;div class="item"&gt;
        &lt;div&gt;
  
          {% for asset in entry.eventThumbnail %}
            {% if asset in entry.eventThumbnail %}
              &lt;img src="{{ asset.getUrl('eventThumbnail') }}" alt="{{ asset.title }}"&gt;
            {% else %}
              &lt;img src="{{ siteUrl }}public/assets/img/grey_image_placeholder.jpg" alt="Skyfoundation"&gt;
            {% endif %}              
          {% endfor %} 
  
          &lt;h2&gt;{{ entry.title }}&lt;/h2&gt;
          &lt;span&gt;{{ entry.subtitle }}&lt;/span&gt;
          &lt;p&gt;{{ entry.eventBlurp}}&lt;/p&gt;
  
          {% for block in entry.eventOrganiser %}
            {% if block.type == "eventDate" %}
              &lt;div class="ticket-cart"&gt; 
                &lt;a href="{{ block.ticketLink }}" class="ticket-btn"&gt;Buy Ticket&lt;/a&gt;
                &lt;div&gt;{{ block.ticketLeftover }} / &lt;i&gt;{{ block.ticketAvail }}&lt;/i&gt; tickets left&lt;/div&gt;
              &lt;/div&gt;
            {% endif %}
          {% endfor %}
  
        &lt;/div&gt;
      &lt;/div&gt;
    {% endfor %}
  
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-17T03:49:08.253Z
Comments.Text: is `year` set? is `month` set? Do `startDate` and `endDate` have sensible values? Once you have those values correct, you will want to loop over the `monthEvents` entries
Comments.UserDisplayName: Marion Newlevant
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-20T00:29:20.743Z
Comments.Text: Both year and month are set. But with limited of coding skills to how to write the correct code to display the entries for each month. It would be good if you show me how.
Comments.UserDisplayName: William Spark
Tags: <templating><datetime><entries-field>
Title: How to display entries relevent to date assigned
ThreadText: # How to display entries relevent to date assigned
  
  (Asked by: username_0 on 2017-02-16)
  
  I am creating a website for not-for-profit organization that help victum of domestic violence. I have a page called Event which display all fund raising events under each month.
  
  I have setup Date/Time field and 12 months tabs and want to know how to display the entries for each month. For example I assign two entries for Feb and when I click on Feb tab, the entries will display.
  
  Here is the sample code I wrote and copied username_1 username_1's suggestion but when I tested it does not work. Any ideas?
  
  Here is what my html structure to display the entries for each month.
  
  ```
  <div class="recent-events2">
    <ul class="month-tabs">
      <li{% set startDate = year~'-'~month~'-01' %}</li>
    </ul>
  
    <div class="events">
  
      {% set monthEvents = craft.entries
        .section('events')
        .dateField(['and', '>= '~startDate, '< '~endDate])
      %}
      <div class="item">
        <div>
  
          {% for asset in entry.eventThumbnail %}
            {% if asset in entry.eventThumbnail %}
              <img src="{{ asset.getUrl('eventThumbnail') }}" alt="{{ asset.title }}">
            {% else %}
              <img src="{{ siteUrl }}public/assets/img/grey_image_placeholder.jpg" alt="Skyfoundation">
            {% endif %}              
          {% endfor %} 
  
          <h2>{{ entry.title }}</h2>
          <span>{{ entry.subtitle }}</span>
          <p>{{ entry.eventBlurp}}</p>
  
          {% for block in entry.eventOrganiser %}
            {% if block.type == "eventDate" %}
              <div class="ticket-cart"> 
                <a href="{{ block.ticketLink }}" class="ticket-btn">Buy Ticket</a>
                <div>{{ block.ticketLeftover }} / <i>{{ block.ticketAvail }}</i> tickets left</div>
              </div>
            {% endif %}
          {% endfor %}
  
        </div>
      </div>
    {% endfor %}
  
    </div>
  
  </div>
  
  ```
  
  **Tags:** templating, datetime, entries-field
  
  > **Comments:**
  > **username_1**: is `year` set? is `month` set? Do `startDate` and `endDate` have sensible values? Once you have those values correct, you will want to loop over the `monthEvents` entries  
  > **username_0**: Both year and month are set. But with limited of coding skills to how to write the correct code to display the entries for each month. It would be good if you show me how.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-17. Score: 1
  
  Assuming your date/time field is called `dateField`, and your entries channel is `events`.
  
  You want to fetch just the entries that have dates in that month. You can do that like this:
  
  If you know the year and the month, the start of the month is (`~` is the twig string concatination operator):
  
  ```
  {% set startDate = year~'-'~month~'-01' %}
  
  ```
  
  And the start of the next month is:
  
  ```
  {% set endDate = startDate|date_modify('+1 month')|date('Y-m-d') %}
  
  ```
  
  We use twig's [date\_modify](http://twig.sensiolabs.org/doc/2.x/filters/date_modify.html) filter to get the start of the next month, and then twig's [date](http://twig.sensiolabs.org/doc/2.x/filters/date.html) filter to convert that to a string.
  
  Now you can fetch the entries for the month. You want ones where the `dateField` is on or after `startDate` and before `endDate`.
  
  ```
  {% set monthEvents = craft.entries
    .section('events')
    .dateField(['and', '>= '~startDate, '< '~endDate])
  %}
  
  ```
  
  
  ---
  
  