Solved

Email template variable for the prior month

  • 13 December 2023
  • 2 replies
  • 44 views

Userlevel 4
Badge +7

Hi all,

Simple question here: is it possible to use the built-in Klaviyo date personalization functions to get a full name for the prior month?

This article explains how you can use variables like `{% current_month_name %}` to get the name of the current month (e.g., “December”).

However, for my use case, I want the name of the prior month (e.g., “November”).

Is this possible using the built-in date personalization functions? Any ideas?

 

Cheers,

Kevin.

icon

Best answer by Taylor Tarpley 22 December 2023, 21:59

View original

2 replies

Userlevel 7
Badge +60

Hi @KeviSunshine

 

Thanks for sharing your question with us! 

 

This is a great question! I’ll need to follow up with our editor team to confirm whether or not this would be possible. I will circle back with an answer when I have one.

 

Thanks for participating in the Community!

-Taylor 

Userlevel 7
Badge +60

Hi @KeviSunshine

 

Thanks for your patience! 

 

While we currently don’t have that functionality within the variable, you can use this workaround suggested by one of our editor team members! 

{% today "%Y-%m-%d" as today %} {% with today|format_date_string|date:'n' as today %}
{% if today = '2' %}
January
{% elif today = '3' %}
February
{% elif today = '4' %}
March
{% elif today = '5' %}
April
{% elif today = '6' %}
May
{% elif today = '7' %}
June
{% elif today = '8' %}
July
{% elif today = '9' %}
August
{% elif today = '10' %}
September
{% elif today = '11' %}
October
{% elif today = '12' %}
November
{% elif today = '1' %}
December
{% endif %}
{% endwith %}

Hope this helps!

-Taylor 

Reply