Expand my Community achievements bar.

SOLVED

How to write an expression to use in email to check a field date equals today

Avatar

Level 1

Hi there,

 

May I ask how can I write an expression to check a condition in my email - to check if product > field date value = today? I tried the below and didn't seem to work. My product date field format is "2024-12-19".

 

{%#if productDate = currentTimeInMillis() %}

 

Thanks,

Amanda

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

You can validate it on the following lines 

{%let a = now %} 
{%let b = toDateTimeOnly("2024-12-19T09:57:27.980Z") %} 
{%let c = dateDiff(b,a) %} 

{%#if c =0 %} // If the difference is zero, product field date is today
render_1
{%else%} 
default_render 
{%/if%}

View solution in original post

3 Replies

Avatar

Level 1

May need to try something like this  {%#if toDateTimeOnly(currentTimeInMillis()) == toDateTimeOnly(productDate) %}

Avatar

Correct answer by
Employee Advisor

You can validate it on the following lines 

{%let a = now %} 
{%let b = toDateTimeOnly("2024-12-19T09:57:27.980Z") %} 
{%let c = dateDiff(b,a) %} 

{%#if c =0 %} // If the difference is zero, product field date is today
render_1
{%else%} 
default_render 
{%/if%}

Avatar

Level 1

Hey @Mohan_Dugganab, do you know how i can convert the now (which is in UTC time) to local Sydney time (noting Australia has a few time zones based on states so this got to be Sydney). Thanks!