CMS Development

Anton
Experto reconocido | Partner nivel Diamond
Experto reconocido | Partner nivel Diamond

Show HubDB entries till today

resolver

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 Me gusta
1 Soluciones aceptada
tjoyce
Solución
Experto reconocido | Partner nivel Elite
Experto reconocido | Partner nivel Elite

Show HubDB entries till today

resolver

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.

Ver la solución en mensaje original publicado

3 Respuestas 3
tjoyce
Solución
Experto reconocido | Partner nivel Elite
Experto reconocido | Partner nivel Elite

Show HubDB entries till today

resolver

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
Experto reconocido | Partner nivel Diamond
Experto reconocido | Partner nivel Diamond

Show HubDB entries till today

resolver

@tjoyce

thanks for the support!

I've tested the output with 

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

but the only thing I've saw was "null" Emoticono frustrado

 

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
Experto reconocido | Partner nivel Elite
Experto reconocido | Partner nivel Elite

Show HubDB entries till today

resolver

Awesome @Anton - glad you got it working.

0 Me gusta