<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Filter data by date range in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/458138#M24020</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60000"&gt;@ben-duchy&lt;/a&gt;&amp;nbsp;can you mark this topic as solved if this solved your problem?&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jul 2021 12:56:35 GMT</pubDate>
    <dc:creator>Indra</dc:creator>
    <dc:date>2021-07-13T12:56:35Z</dc:date>
    <item>
      <title>Filter data by date range</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/457132#M23990</link>
      <description>&lt;P&gt;I’ve been tasked with displaying rows based on a set of date ranges with an overall number of how many rows meet this criteria. This date range will need to be editable within the page editor but for now I can't even get a hard coded version to work!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought something along these lines, but no luck!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set table = hubdb_table_rows(12345467) %}

{% for row in table %}
    {% set plot = unixtimestamp(row.plot_date) %}
    {% set startdate1 = "01/07/2021"|strtodate("dd/MM/yyyy") %}
    {% set enddate1 = "30/09/2021"|strtodate("dd/MM/yyyy") %}
  
    {% if plot | datetimeformat('%e/%m/%Y') &amp;gt;= startdate1 %}
      {% if plot | datetimeformat('%e/%m/%Y') &amp;lt;= enddate1 %}
      Display row data
      {% endif %}
    {% endif %}
  
  {% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To summerise, it should show:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Between 1 July 2020 – 30 September 2020&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;Unsold Plots = 10&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;Row(s) information displayed&lt;/LI&gt;&lt;/UL&gt;&lt;LI&gt;Reserved plots = 20&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;Row(s) information displayed&lt;/LI&gt;&lt;/UL&gt;&lt;LI&gt;Exchanged plots = 25&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;Row(s) information displayed&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;Total plots = 55&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 11:21:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/457132#M23990</guid>
      <dc:creator>ben-duchy</dc:creator>
      <dc:date>2021-07-12T11:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data by date range</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/457901#M24013</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60000"&gt;@ben-duchy&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you check your previous question?&lt;BR /&gt;&lt;A href="https://community.hubspot.com/t5/CMS-Development/Finding-the-length-of-repeating-dates/td-p/457184" target="_blank"&gt;https://community.hubspot.com/t5/CMS-Development/Finding-the-length-of-repeating-dates/td-p/457184&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's best to format your date by numbers so you can compare if it's a larger of lower number. So best thing to do it to set your date up by&amp;nbsp;%Y%m%d.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code will look like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% set rows = hubdb_table_rows(1234567, "&amp;amp;plot_status__in=Completed&amp;amp;forecast_year__in=20/21") %}

{% set items = {'amount' : 0 } %}

{% for row in rows %}

  {% set cur = row["legal_completion"]|datetimeformat('%Y%m%d') %}
  {% set from = module.from_date|datetimeformat('%Y%m%d') %}
  {% set till = module.till_date|datetimeformat('%Y%m%d') %}

  {% if from &amp;lt;= cur &amp;amp;&amp;amp; cur &amp;lt;= till %}
    {% do items.update({'amount' : items.amount + 1}) %}
  {% endif %}
{% endfor %}

Items in range: {{ items.amount }}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 06:25:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/457901#M24013</guid>
      <dc:creator>Indra</dc:creator>
      <dc:date>2021-07-13T06:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data by date range</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/458138#M24020</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60000"&gt;@ben-duchy&lt;/a&gt;&amp;nbsp;can you mark this topic as solved if this solved your problem?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 12:56:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/458138#M24020</guid>
      <dc:creator>Indra</dc:creator>
      <dc:date>2021-07-13T12:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data by date range</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/458150#M24021</link>
      <description>&lt;P&gt;My apologies, yes of course&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 13:05:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Filter-data-by-date-range/m-p/458150#M24021</guid>
      <dc:creator>ben-duchy</dc:creator>
      <dc:date>2021-07-13T13:05:21Z</dc:date>
    </item>
  </channel>
</rss>

