Skip to main content
KeviSunshine
Expert Problem Solver III
Expert Problem Solver III
December 13, 2023
Solved

Email template variable for the prior month

  • December 13, 2023
  • 2 replies
  • 156 views

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.

    This topic has been closed for replies.
    Best answer by Taylor Tarpley

    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 

    2 replies

    Taylor Tarpley
    Community Manager
    Community Manager
    December 18, 2023

    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 

    Taylor Tarpley
    Community Manager
    Community Manager
    December 22, 2023

    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