Skip to main content
Solved

Calculate number of days until date in email template

  • November 19, 2024
  • 3 replies
  • 58 views

Forum|alt.badge.img+2

Hi

We are creating a email template to reminder customers to use their coupon / voucher. We send through a voucher expiry date as part of the event in UTC format

{{ event|lookup:'Coupon Expiry }}

I like to include in my email a reminder to customers to let them know they have XX days left to use their voucher based on Coupon Expiry Date - Time Now

Like: Your voucher expires in 5 days

Can this be calculated as part of the email email formatting in Klaviyo?

Thanks!

Best answer by retention

Hi ​@jonoroy,

You can try the “timeuntil” filter.  Just make sure to cast your expiry date string as a date object, I’m using the “format_date_string” filter to do this. If you don’t use a specified date for the timeuntil filter, it implies that it is comparing to the time now.

Roughly, this should work:

{{ event|lookup:'Coupon Expiry’|format_date_string|timeuntil }}

You may have to debug it a bit to make it work.

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Taylor Tarpley
Community Manager
Forum|alt.badge.img+60
  • Community Manager
  • 2148 replies
  • November 22, 2024

Hi there ​@jonoroy

 

Thanks for sharing your question with the Community! 

 

This should be possible, can you share what integration owns this coupon? This will inform how you configure the code to show the expiration date.

 

Thanks for participating in the Community!

-Taylor 


retention
Partner - Platinum
Forum|alt.badge.img+62
  • 2025 Champion
  • 920 replies
  • Answer
  • November 23, 2024

Hi ​@jonoroy,

You can try the “timeuntil” filter.  Just make sure to cast your expiry date string as a date object, I’m using the “format_date_string” filter to do this. If you don’t use a specified date for the timeuntil filter, it implies that it is comparing to the time now.

Roughly, this should work:

{{ event|lookup:'Coupon Expiry’|format_date_string|timeuntil }}

You may have to debug it a bit to make it work.


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • November 25, 2024

Hey Jospeh ​@retention,

Thanks so much for this, that worked like a treat!