CMS Development

Mominash
Member

Filter HubDB data based on today's date SOLVE

SOLVE

I am using HubDB to display a list of webinars.

I use the following columns:

event_start_date = start date of the event

event_end_date = end date of the event

landing_page_url = desination URL

 

However, I would not like to display past webinars.

So I need to retreive today's date and make sure that only future events are displayed.

Can I filter these in my overview?

 

My current code is below.

 

 

 

{% set queryparam = "&orderBy=event_start_date" %}

{% set table = hubdb_table_rows(671918, queryparam ) %}
{% if table == [] %}
     <p class='lead'>Sorry, no webinars available.</p>
{% else %}
     <ul> 
          {% for row in table %}
          <li>
               <h2><a href="{{ row.landing_page_url }}">{{ row.hs_name }}</a</h2>                      
          </li>
          {% endfor %}
     </ul>
{% endif %}


Regards
Gameswithgf

0 Upvotes
1 Accepted solution
Anton
Solution
Recognized Expert

Filter HubDB data based on today's date SOLVE

SOLVE

Hi @Mominash,

@dennisedson - thanks for bringing me in 😁

 

yes - this is possible. 
You'll need to adjust your if-statement. 

 

 

{% set queryparam = "&orderBy=event_start_date" %}
{% set table = hubdb_table_rows(671918, queryparam ) %}

<ul>
{% for event in table %}
  {% if  unixtimestamp(local_dt) > data['event_start_date']   and  unixtimestamp(local_dt) < data['event_end_date'] %}
  <li>
  <h2><a href="{{ event.landing_page_url }}">{{ event.hs_name }}</a</h2>
</li>
{% elif table == [] %}
<p class='lead'>Sorry, no webinars available.</p>
{% else %}
	  {# Event is in the past #}
  {% endif %}
{% endfor %}

 

 

 

More about unixtimestamp here and here

 

hope this helps

 

best, 

Anton

Anton Bujanowski Signature

View solution in original post

2 Replies 2
Anton
Solution
Recognized Expert

Filter HubDB data based on today's date SOLVE

SOLVE

Hi @Mominash,

@dennisedson - thanks for bringing me in 😁

 

yes - this is possible. 
You'll need to adjust your if-statement. 

 

 

{% set queryparam = "&orderBy=event_start_date" %}
{% set table = hubdb_table_rows(671918, queryparam ) %}

<ul>
{% for event in table %}
  {% if  unixtimestamp(local_dt) > data['event_start_date']   and  unixtimestamp(local_dt) < data['event_end_date'] %}
  <li>
  <h2><a href="{{ event.landing_page_url }}">{{ event.hs_name }}</a</h2>
</li>
{% elif table == [] %}
<p class='lead'>Sorry, no webinars available.</p>
{% else %}
	  {# Event is in the past #}
  {% endif %}
{% endfor %}

 

 

 

More about unixtimestamp here and here

 

hope this helps

 

best, 

Anton

Anton Bujanowski Signature
dennisedson
HubSpot Product Team
HubSpot Product Team

Filter HubDB data based on today's date SOLVE

SOLVE

Hello @Mominash 

Bringing @Anton in to help out 😀

0 Upvotes