CMS Development

Anton
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Show HubDB entries till today

SOLVE

Hi, 

a few weeks ago I've started this topic in which I've needed to add some "filter" to a module.

@tjoyce done a great job by helping me with it.

 

Now I need to add a constant "show entries, which has a expiry date till *today*". There is a Hub DB Column with a date entry which should work as the filter entry.

 

e.g

- Row1 has an expiry date of 12.09.2018(will be shown in the module)

- Row2 has an expiry date of 10.09.2018(won't be shown in the module, because the expiry date was yesterday)

....

 

I've found this topic and modified the solution for my needs. Unfortunately it doesn't work. 

 

 {% if (row['expiryDate']|datetimeformat('%Y-%m-%j')) >= (local_dt|datetimeformat('%Y-%m-%j')) %}
*LISTING*
{% endif %}

expiryDate = HubDB column name of the datepicker

datetimeformat '%Y-%m-%j' = the format how the HubDB table export(CSV/XLS) looks like.

 

I've also tried to change the local_dt|datetimeformat to the datetimeformat which is set in the HubSpot settings(it's set to "Germany" and the blog settings are set to "medium")...

 

What am I doing wrong?

 

 

regards

Anton

Anton Bujanowski Signature
0 Upvotes
1 Accepted solution
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Show HubDB entries till today

SOLVE

Hey @Anton - I don't use HubDB a whole lot but, I thought dates were converted to Unix timestamps in your database record...

 

What is the output of 

row['expiryDate']

does it look something like this? 1536665594000

If it does, then you can do this:

 {% if (row['expiryDate'] >= unixtimestamp(local_dt) %}
    *LISTING*
 {% endif %}

If it doesn't, you may be able to do this:

 

 {% if (unixtimestamp(row['expiryDate']) >= unixtimestamp(local_dt) %}
    *LISTING*
 {% endif %}

 


If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

View solution in original post

3 Replies 3
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Show HubDB entries till today

SOLVE

Hey @Anton - I don't use HubDB a whole lot but, I thought dates were converted to Unix timestamps in your database record...

 

What is the output of 

row['expiryDate']

does it look something like this? 1536665594000

If it does, then you can do this:

 {% if (row['expiryDate'] >= unixtimestamp(local_dt) %}
    *LISTING*
 {% endif %}

If it doesn't, you may be able to do this:

 

 {% if (unixtimestamp(row['expiryDate']) >= unixtimestamp(local_dt) %}
    *LISTING*
 {% endif %}

 


If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

Anton
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Show HubDB entries till today

SOLVE

@tjoyce

thanks for the support!

I've tested the output with 

{{ row['expiryDate'] | pprint }}

but the only thing I've saw was "null" Smiley Frustrated

 

After some deeper resarch, your "idea" with the unixtimestamp", some testing, more research and testing again I've found the solution which worked

 

{% if (row['expiryDate']|unixtimestamp) >= (local_dt|unixtimestamp - 28800000) %}
*LISTING*
{% endif %}

Thanks again man!

 

regards

Anton Bujanowski Signature
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Show HubDB entries till today

SOLVE

Awesome @Anton - glad you got it working.

0 Upvotes