# Filters not working properly?

**URL:** <https://community.hubspot.com/t/filters-not-working-properly/80832>\
**Category:** CMS Development\
**Tags:** email\
**Created:** [May 9, 2023, 2:49pm UTC](https://community.hubspot.com/t/filters-not-working-properly/80832 "2023-05-09T14:49:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdanessa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sdanessa/32/198579_2.png) [@sdanessa](https://community.hubspot.com/u/sdanessa)\
**Post date:** [May 9, 2023, 2:49pm UTC](https://community.hubspot.com/t/filters-not-working-properly/80832/1 "2023-05-09T14:49:27Z")

</div>

I have a Date Picker Property (enrollment\_date), that I’m trying to use to calculate dates inside emails.  
My first try was to use it directly:  
{% set future\_date\_1 = contact.enrollment\_date|plus\_time(3, ‘days’) %}  
Which doesn’t work because the plus\_time requires a datetime object, and the datepicker apparently returns a string **(Issue 1)**:  
{{ contact.enrollment\_date|pprint }}

(String: 5/1/23)  
Because of that, I’ve tried to use strtotime, but I found that unless I pass the entire format, it won’t work properly **(Issue/bug 2)**.  
For example this doesn’t work:

{% set enrollment\_date\_datetime = contact.enrollment\_date|strtotime(“M/d/yy”) %}  
So in order for me to create a string with the entire date in the right format, I’ll have to first use something like this:

{% set enddate = (date\_parts[2] + “-” + date\_parts[0] + “-” + date\_parts[1] + “T14:31:30+0530”)|strtotime(“yyyy-MM-dd’T’HH:mm:ssZ”) %}  
However, in order to do that, I need to get the parts from my date, and when trying the following, I’m not being able to do so:  
**(Issue/Bug 3).** Seems like the SPLIT filter is not working on the type of sting that is returned by the datepicker property, even though the pprint is saying that is a string

Example for context. The Following is parsed correctly:

{% set date\_string = “5/1/23” %}  
{% set date\_parts = date\_string|split(‘/’) %}

Day: {{ date\_parts[1] }}  
Month: {{ date\_parts[0] }}  
Year: {{ date\_parts[2] }}

Result:

Day: 1  
Month: 5  
Year: 23

---- The Following is parsed incorrectly:

{% set date\_string = contact.enrollment\_date %}  
{% set date\_parts = date\_string|split(‘/’) %}

Day: {{ date\_parts[1] }}  
Month: {{ date\_parts[0] }}  
Year: {{ date\_parts[2] }}

Result:  
Day:  
Month: 5/1/23  
Year:

---- This is also parsed incorrectly

{% set date\_string = contact.enrollment\_date|string %}  
{% set date\_parts = date\_string|split(‘/’) %}  
{% set date\_parts = date\_parts[0]|split(‘/’) %}

Day: {{ date\_parts[1] }}  
Month: {{ date\_parts[0] }}  
Year: {{ date\_parts[2] }}

Result:  
Day:  
Month: 5/1/23  
Year:

Other alternatives that I’ve tried unssuccessfully:

---- This is also parsed incorrectly (Added STRING filter multiple times)

{% set date\_string = contact.enrollment\_date|string %}  
{% set date\_parts = date\_string|string|split(‘/’) %}  
{% set date\_parts = date\_parts[0]|string|split(‘/’) %}

Day: {{ date\_parts[1] }}  
Month: {{ date\_parts[0] }}  
Year: {{ date\_parts[2] }}

Result:  
Day:  
Month: 5/1/23  
Year:

---- This is also parsed incorrectly

{% set date\_string = contact.enrollment\_date|date(‘%m/%d/%y’) %}  
{% set date\_parts = date\_string|split(‘/’) %}  
Day: {{ date\_parts[1] }}  
Month: {{ date\_parts[0] }}  
Year: {{ date\_parts[2] }}

Result:

Day:  
Month:  
Year:

---- This is also parsed incorrectly

{% set date\_string = contact.enrollment\_date %}  
{% set date\_parts = date\_string|regex\_findall(‘\d+’) %}  
Day: {{ date\_parts[1] }}  
Month: {{ date\_parts[0] }}  
Year: {{ date\_parts[2] }}

Result:

Day:  
Month:  
Year:

I’d appreciate your help to try to debug this.  
Understanding that returning the date picker as a string can’t be changed, the ideal outcome would be to solve Issue 2, to make the following work:  
{% set enrollment\_date\_datetime = contact.enrollment\_date|strtotime(“M/d/yy”) %}  
And as a last resource, see why the string that is returned can’t be split by the split filter correctly.  
Thanks!

---

<div class="post-metadata">

**Author:** ![JBeatty](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbeatty/32/52252_2.png) [@JBeatty](https://community.hubspot.com/u/JBeatty)\
**Post date:** [May 9, 2023, 4:44pm UTC](https://community.hubspot.com/t/filters-not-working-properly/80832/2 "2023-05-09T16:44:18Z")

</div>

Hi @sdanessa,

From the docs: [HubL filters - HubSpot docs](https://developers.hubspot.com/docs/cms/hubl/filters)

> **Please note:** you can apply HubL filters to [personalization tokens](https://knowledge.hubspot.com/website-pages/personalize-your-content), such as contact and company tokens, on HubSpot CMS and blog pages, but not in emails.
> 
> * * *

I think this is the main source of your issues here. As a work around I would try formatting the property using a workflow and copying that to another property, and using that vlaue directly within the email.

Best,

---

<div class="post-metadata">

**Author:** ![sdanessa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sdanessa/32/198579_2.png) [@sdanessa](https://community.hubspot.com/u/sdanessa)\
**Post date:** [May 9, 2023, 5:47pm UTC](https://community.hubspot.com/t/filters-not-working-properly/80832/3 "2023-05-09T17:47:57Z")

</div>

Thanks so much, Joshua!  
I totally missed that line of the docs.  
Your workflow idea makes sense, although I think it will be a bit convoluted for this particular use case, since there are quite a few other dates to calculate.  
Can you by any chance think of some function that brings the value of the property earlier, that is available inside emails, so I can copy only the value, and operate on that string inside the email, instead?  
I’ve tried with this, after reading your message:  
{% set date\_string2 = personalization\_token(“contact.enrollment\_date”, “1/1/23”) %}  
but it’s also not filterable.  
I imagine bc it’s processed later in the code.  
Cheers!

---

<div class="post-metadata">

**Author:** ![JBeatty](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbeatty/32/52252_2.png) [@JBeatty](https://community.hubspot.com/u/JBeatty)\
**Post date:** [May 9, 2023, 10:12pm UTC](https://community.hubspot.com/t/filters-not-working-properly/80832/4 "2023-05-09T22:12:50Z")

</div>

In my testing around programmable emails any time a variable touches anything related to a pesronalization token, all the stuff touching that variable stops working. So I do not know of any work arounds here.

Best,

---

<div class="post-metadata">

**Author:** ![sdanessa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sdanessa/32/198579_2.png) [@sdanessa](https://community.hubspot.com/u/sdanessa)\
**Post date:** [May 10, 2023, 8:37am UTC](https://community.hubspot.com/t/filters-not-working-properly/80832/5 "2023-05-10T08:37:22Z")

</div>

Thanks again, Joshua.
