# inserting date into email template

**URL:** <https://community.hubspot.com/t/inserting-date-into-email-template/24026>\
**Category:** CMS Development\
**Created:** [August 11, 2020, 6:06am UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026 "2020-08-11T06:06:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikram-mit](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/vikram-mit/32/39641_2.png) [@vikram-mit](https://community.hubspot.com/u/vikram-mit)\
**Post date:** [August 11, 2020, 6:06am UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/1 "2020-08-11T06:06:45Z")

</div>

i have email template for our lead follow up emails where we usually suggest a date 2 business days of sending the email. currently, it is a pain to manually update the date every time we send email. is there a way to insert it dynamically the way we can do the personalization attributes?

---

<div class="post-metadata">

**Author:** ![kamlesh\_k](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kamlesh_k/32/45996_2.png) [@kamlesh\_k](https://community.hubspot.com/u/kamlesh_k)\
**Post date:** [August 12, 2020, 8:27am UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/2 "2020-08-12T08:27:49Z")

</div>

There is no token that you can use that inserts the date.

One thing you could try is a workflow to manage the email send. If you use a workflow then you can have a field with the date that triggers the email then you can use a personalization token for a date field.

---

<div class="post-metadata">

**Author:** ![fdasilva](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/fdasilva/32/31184_2.png) [@fdasilva](https://community.hubspot.com/u/fdasilva)\
**Post date:** [January 22, 2021, 8:55pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/3 "2021-01-22T20:55:12Z")

</div>

Can we please get on creating such an option. Competitors like Salesloft and others have had this implemented for years.

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [January 22, 2021, 11:57pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/4 "2021-01-22T23:57:12Z")

</div>

@vikram-mit

You don’t need a personalization token or workflow. You just need one little line of HubL -

`{{ datetimeformat(local_dt, '%B %e, %Y') }}`

You can hardcode it into a module or you can even paste it into the HTML of a richtext module. Note: if placed in a richtext module it’ll show as code in the page editor, but the date will be rendered in preview and on send). Ex:  
Page Editor (Do not type directly into the rich text, open the source code)  
 ![]()

 ![36894i48CF748FB0B6A19C.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/3/f39e8c883a44ceaba8719243bcfe1a9dfdec58f7.png)

Preview

 ![36895i833E3C3124A9FBE5.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/d/fd96be2b9c53a89a0f269d6b499d88d3b88a9ab9.png)

---

<div class="post-metadata">

**Author:** ![LoraBergeron](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lorabergeron/32/75439_2.png) [@LoraBergeron](https://community.hubspot.com/u/LoraBergeron)\
**Post date:** [January 28, 2021, 5:12pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/5 "2021-01-28T17:12:49Z")

</div>

Hi,

I need to add a variable date as well, but I’d like to add, for example, 21 days after the current date. I’m using this to communicate an expiration date that changes with an email send from a workflow. It can’t link to the content.update information. It needs to link to whatever date the email is sent out. Can you help me?  
Thanks in advance,

Lora B

---

<div class="post-metadata">

**Author:** ![kaitlynwells](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kaitlynwells/32/31851_2.png) [@kaitlynwells](https://community.hubspot.com/u/kaitlynwells)\
**Post date:** [October 27, 2021, 4:53pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/6 "2021-10-27T16:53:56Z")

</div>

Found this while looking for a way to insert a dynamic date into an automatic email, this worked perfectly - thank you!

---

<div class="post-metadata">

**Author:** ![Rob\_Gordon](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rob_gordon/32/188587_2.png) [@Rob\_Gordon](https://community.hubspot.com/u/Rob_Gordon)\
**Post date:** [November 11, 2021, 5:18pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/7 "2021-11-11T17:18:50Z")

</div>

Did you manage to insert this into a template? For a 1:1 email? Or only in a Marketing email?

Thanks  
Rob

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [January 28, 2021, 5:36pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/8 "2021-01-28T17:36:35Z")

</div>

@LoraBergeron

You can use the plus\_time filter to get a future date from the current date, like so:

```lia-code-sample
{% set future_date = local_dt|plus_time(21, 'days')%}
{{ datetimeformat(future_date, '%B %e, %Y') }}

```

---

<div class="post-metadata">

**Author:** ![CCassidy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ccassidy/32/73373_2.png) [@CCassidy](https://community.hubspot.com/u/CCassidy)\
**Post date:** [May 19, 2021, 8:58am UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/9 "2021-05-19T08:58:47Z")

</div>

This is great!!

I’ve been looking through HubL, some really good stuff.

One more additional question on this one.

in a workflow within an email can I set the date as ‘end of the month’ for example: Available until the end of **May**

So then June arrives and it will prepopulate to now be Available until the end of **June.**

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [May 20, 2021, 8:02pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/10 "2021-05-20T20:02:38Z")

</div>

@CCassidy You can grab the current month like so :

`{{ datetimeformat(local_dt, '%B') }} `

So at the time of me posting this that code would output “May” then on June 1st it’ll start outputting “June”.

---

<div class="post-metadata">

**Author:** ![Glay\_Imutan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/glay_imutan/32/85667_2.png) [@Glay\_Imutan](https://community.hubspot.com/u/Glay_Imutan)\
**Post date:** [August 24, 2021, 12:33pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/11 "2021-08-24T12:33:34Z")

</div>

Hello Alyssa,

Is there a way how to change the format of personalization tokens? For example, instead of 7/14/2022, the output will be Jul 14, 2022.

Here’s what it looks like from the source code:

![Screen Shot 2021-08-24 at 8.30.30 PM.png](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/0/f/0fb6cdd87069f8dff2a7d0f28443b4665490186d_2_690x24.png)

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [August 24, 2021, 1:21pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/12 "2021-08-24T13:21:17Z")

</div>

[@Glay\_Imutan](https://community.hubspot.com/t5/user/viewprofilepage/user-id/207497) I believe using the filter instead of the function is better suited for personalization tokens:

`{{ company.subscription_end_date|datetimeformat('%b %e, %Y') }}`

---

<div class="post-metadata">

**Author:** ![Glay\_Imutan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/glay_imutan/32/85667_2.png) [@Glay\_Imutan](https://community.hubspot.com/u/Glay_Imutan)\
**Post date:** [August 24, 2021, 6:33pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/13 "2021-08-24T18:33:28Z")

</div>

That was fast! Thanks Alyssa. I tried the script above however I think I missed something?  
Here’s what it looks like from the source code:

![Screen Shot 2021-08-25 at 2.30.02 AM.png](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/1/0/10bbf956751a3794eee2c14b94aa62c7f5996f4a_2_690x30.png)

It doesn’t reflect the date as it should be. It appears blank on the “preview” mode:

 ![Screen Shot 2021-08-25 at 1.56.26 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/d/1d31350fb96d9dc54dad6188cc4f4844fef9f3c2.png)

What could be the problem?

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [August 24, 2021, 6:42pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/14 "2021-08-24T18:42:41Z")

</div>

[@Glay\_Imutan](https://community.hubspot.com/t5/user/viewprofilepage/user-id/207497) Sorry, I completely missed that this post was about email. Unfortantely, Hubspot does not support formatting on contact properties in email. 😔

As stated in their [documentation](https://developers.hubspot.com/docs/cms/hubl/filters?_ga=2.10775348.1868918060.1629811119-95174932.1629811119) :  
“Please note that using filters on **any** personalization variables (such as but not limited to contacts, company, and deal variables) is not currently supported for email in HubSpot due to how emails are rendered”

---

<div class="post-metadata">

**Author:** ![Glay\_Imutan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/glay_imutan/32/85667_2.png) [@Glay\_Imutan](https://community.hubspot.com/u/Glay_Imutan)\
**Post date:** [August 24, 2021, 6:52pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/15 "2021-08-24T18:52:38Z")

</div>

Oh no worries! thanks for checking and for helping me. Greatly appreciate your effort 😃

I’ll just use zapier to do the format.

---

<div class="post-metadata">

**Author:** ![spogue](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/spogue/32/73227_2.png) [@spogue](https://community.hubspot.com/u/spogue)\
**Post date:** [September 9, 2021, 3:29pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/16 "2021-09-09T15:29:49Z")

</div>

@alyssamwilie This is really great, thanks for the solution. I’m curious to how this would work if I only wanted to show the next 4 business days? If its showing today (a Thursday), it would show Friday, Monday, and Tuesday. Is that possible through Hubl?

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [September 22, 2021, 11:43am UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/17 "2021-09-22T11:43:55Z")

</div>

@spogue Not sure if you can get them concurrently but you can use multiple plus\_time calls to get the next three days and %A in the format to get the weekday.  
{{ datetimeformat(local\_dt|plus\_time(1, ‘days’), “%A”) }}  
{{ datetimeformat(local\_dt|plus\_time(2, ‘days’), “%A”) }}  
{{ datetimeformat(local\_dt|plus\_time(3 , ‘days’), “%A”) }}

---

<div class="post-metadata">

**Author:** ![spogue](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/spogue/32/73227_2.png) [@spogue](https://community.hubspot.com/u/spogue)\
**Post date:** [September 22, 2021, 1:08pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/18 "2021-09-22T13:08:08Z")

</div>

@alyssamwilie Makes sense. Have you ever seen code to only show business days?

For example, if I took the way you just wrote the code, but I only wanted to show the next 3 business days, is there a way to “skip” weekdays if one of those days is a Saturday or Sunday? Like this:

Friday, September 24, 2021

Monday, September 27, 2021

Tuesday, September 28, 2021

Thanks again for the help.

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [September 22, 2021, 1:26pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/19 "2021-09-22T13:26:05Z")

</div>

@spogue You can use a for loop and if statements to increase the plus\_time if the weekday lands on a Saturday or Sunday. You’ll probably want to put this in a custom module instead of directly in the email though.

```lia-code-sample
{% for day in [1, 2, 3] %}
 {% if datetimeformat(local_dt|plus_time(day,'days'), '%A') == "Saturday" %}
 {{ datetimeformat(local_dt|plus_time(day + 2,'days'), '%A, %B %e, %Y') }}<br>
 {% elif datetimeformat(local_dt|plus_time(day,'days'), '%A') == "Sunday" %}
 {{ datetimeformat(local_dt|plus_time(day + 1,'days'), '%A, %B %e, %Y') }}<br>
 {% else %}
 {{ datetimeformat(local_dt|plus_time(day,'days'), '%A, %B %e, %Y') }}<br>
 {% endif %}
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![ShiranA](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/shirana/32/12800_2.png) [@ShiranA](https://community.hubspot.com/u/ShiranA)\
**Post date:** [July 3, 2022, 1:36pm UTC](https://community.hubspot.com/t/inserting-date-into-email-template/24026/20 "2022-07-03T13:36:29Z")

</div>

Thank you! This was very helpful!

[Next page](https://community.hubspot.com/t/inserting-date-into-email-template/24026.md?page=2)
