<?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 hubdb filter for last month/year in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/hubdb-filter-for-last-month-year/m-p/749502#M60964</link>
    <description>&lt;P&gt;How do I get last month as a filter for a HubDB?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set current_month = local_dt|datetimeformat("%m") %}&lt;/P&gt;&lt;P&gt;{% set current_year = local_dt|datetimeformat("%y") %}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set previous_month = ????|datetimeformat("%m") %}&lt;/P&gt;&lt;P&gt;{% set previous_year = ????|datetimeformat("%y") %}&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2023 16:09:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-01-31T16:09:21Z</dc:date>
    <item>
      <title>hubdb filter for last month/year</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/hubdb-filter-for-last-month-year/m-p/749502#M60964</link>
      <description>&lt;P&gt;How do I get last month as a filter for a HubDB?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set current_month = local_dt|datetimeformat("%m") %}&lt;/P&gt;&lt;P&gt;{% set current_year = local_dt|datetimeformat("%y") %}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set previous_month = ????|datetimeformat("%m") %}&lt;/P&gt;&lt;P&gt;{% set previous_year = ????|datetimeformat("%y") %}&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 16:09:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/hubdb-filter-for-last-month-year/m-p/749502#M60964</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-31T16:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: hubdb filter for last month/year</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/hubdb-filter-for-last-month-year/m-p/750112#M61012</link>
      <description>&lt;P&gt;{% set current_month = local_dt|datetimeformat("%m") %}&lt;/P&gt;
&lt;P&gt;{% set current_year = local_dt|datetimeformat("%y") %}&lt;/P&gt;
&lt;P&gt;{% set previous_month = current_month|default(1)|int - 1 %}&lt;/P&gt;
&lt;P&gt;{% set previous_year = current_year|int - 1 %}&lt;/P&gt;
&lt;P&gt;{% if previous_month == 0 %}&lt;/P&gt;
&lt;P&gt;{% set previous_month = 12 %}&lt;/P&gt;
&lt;P&gt;{% endif %}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Test: {{ previous_month }}, {{ previous_year }}, {{ current_year }}&lt;BR /&gt;&lt;BR /&gt;This should return: 1, 22, 23 &lt;BR /&gt;since today is Feb 1, 2023&lt;BR /&gt;&lt;BR /&gt;You can use those numbers as filters for the values in your query:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;{{ set query = "year=" + previous_year }} &lt;/PRE&gt;
&lt;PRE&gt;{{ hubdb_table_rows(&amp;lt;tableId&amp;gt;, query) }}&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Hope that helps!&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 16:05:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/hubdb-filter-for-last-month-year/m-p/750112#M61012</guid>
      <dc:creator>Brownstephen101</dc:creator>
      <dc:date>2023-02-01T16:05:38Z</dc:date>
    </item>
  </channel>
</rss>

