<?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: More or less than on dates in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371620#M18694</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;, great idea, I wasn't even aware of this method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately I can't get it to work correctly as its pulling in all rows to show 'A content' or 'B content' depending on the less / more arrow used. It's not filtering them!&lt;BR /&gt;&lt;BR /&gt;Do I need to do anything different in HubDB?&lt;/P&gt;</description>
    <pubDate>Fri, 18 Sep 2020 08:30:34 GMT</pubDate>
    <dc:creator>ben-duchy</dc:creator>
    <dc:date>2020-09-18T08:30:34Z</dc:date>
    <item>
      <title>More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/370913#M18644</link>
      <description>&lt;P&gt;Does anyone know if it's possible to run an if statement based on a date in hubdb?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a set of dates in a column which pulls through fine, but when trying to amend it with an if statement, it doesn't work!&lt;BR /&gt;&lt;BR /&gt;I am trying to display 1 of 2 items depending on the date. e.g. if it's before 1 March 2021 then show A content else show B content&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;{% elif row["anticipated-build-completion"] | datetimeformat('%e %B %Y') &amp;gt; '1 March 2021' %}&lt;BR /&gt;&lt;/STRONG&gt;Show A content&lt;BR /&gt;&lt;STRONG&gt;{% else %}&lt;BR /&gt;&lt;/STRONG&gt;Show B content&lt;BR /&gt;&lt;STRONG&gt;{% endif %}&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 15:29:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/370913#M18644</guid>
      <dc:creator>ben-duchy</dc:creator>
      <dc:date>2020-09-16T15:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/370952#M18648</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;the problem is because you are formatting it, then trying to use math/logic on a formatted date. Instead, you should try using the &lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions#unixtimestamp" target="_blank" rel="noopener"&gt;unixtimestamp&lt;/A&gt; equivalant for the date. This way you are just comparing two numbers with each other so the computer can understand what you're doing... so something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% if unixtimestamp(row.datetimeobject) &amp;lt; 1614556800 %}
I'm a date before March 1st 2021!
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 16:08:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/370952#M18648</guid>
      <dc:creator>stefen</dc:creator>
      <dc:date>2020-09-16T16:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/370980#M18649</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60000"&gt;@ben-duchy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you open you if statement with an else if rather than an if. try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% if row["anticipated-build-completion"] | datetimeformat('%e %B %Y') &amp;gt; '1 March 2021' %}
Show A content
{% else %}
Show B content
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 17:42:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/370980#M18649</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2020-09-16T17:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371614#M18693</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73772"&gt;@Kevin-C&lt;/a&gt;, thanks for your reply. It's part of a wider condition - I forgot to mention that.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 08:11:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371614#M18693</guid>
      <dc:creator>ben-duchy</dc:creator>
      <dc:date>2020-09-18T08:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371620#M18694</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;, great idea, I wasn't even aware of this method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately I can't get it to work correctly as its pulling in all rows to show 'A content' or 'B content' depending on the less / more arrow used. It's not filtering them!&lt;BR /&gt;&lt;BR /&gt;Do I need to do anything different in HubDB?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 08:30:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371620#M18694</guid>
      <dc:creator>ben-duchy</dc:creator>
      <dc:date>2020-09-18T08:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371816#M18706</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60000"&gt;@ben-duchy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ahh gotcha.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder if the mutating/formatting of the data is getting in the way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a best practice we try to avoid mutating data until the last possible time (usually displaying it). We do this because mutating data back and forth can make it hard to track and understand the state of the data. Also when comparing a dynamic value with a static value we try to match the static value's format to that of the dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To test if this might be the case try printing the variable and comparing manually:&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;{{ row["anticipated-build-completion"] }}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically take a look at that output and then try to modify the static date format you're checking against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should make the bug easier to assess.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="7"&gt;&lt;STRONG&gt;EDIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;Im working through a test now will follow up soon&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 18:43:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371816#M18706</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2020-09-18T18:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371819#M18708</link>
      <description>&lt;P&gt;Hey again &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/60000"&gt;@ben-duchy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% set staticDate = "2021-03-01T00:00:00+0000"|strtotime("yyyy-MM-dd'T'HH:mm:ssZ") %}{# the date you're checking against #}
{% set dynmDate = row["anticipated-build-completion"] %} {# your dynamic date #}


{% if dynmDate|between_times(staticDate, 'days') &amp;gt;= 1 %} {# Check using between times #}

  {# if the date is before teh staticDate #}

  {% elif %}

  {# if the date is after teh staticDate #}

{% endif %}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Sep 2020 18:58:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/371819#M18708</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2020-09-18T18:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: More or less than on dates</title>
      <link>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/372093#M18722</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73772"&gt;@Kevin-C&lt;/a&gt; thats now working, although I had to swap out 'elif' for 'else' (not sure why that would make a difference).&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 10:31:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/More-or-less-than-on-dates/m-p/372093#M18722</guid>
      <dc:creator>ben-duchy</dc:creator>
      <dc:date>2020-09-21T10:31:13Z</dc:date>
    </item>
  </channel>
</rss>

