내 커뮤니티 업적 표시줄을 확대합니다.

Join Adobe Journey Optimizer product experts for a live Ask Me Anything on October 15th at 8 AM PT about Expanding Your Mobile Reach with RCS & WhatsApp in AJO!

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Check The Date Condition like Date occurs after 30 days in If condition in JSON

Avatar

Level 2

We are trying to find the right Json where check the date occurs less or greater then xx days after today. please find the below sample. Birthdate has the year init. Do we have any other option to crack this?

 

{%#if profile.person.birthDate occurs <=30 days after today%} {"content_id":"sample": "{{profile.person.name.firstName}}"} {%/if%}

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee Advisor

@gengaipandi11 ,

To compare dates in JSON & to check if the birthdate occurs less or greater than xx days after today, you can use-

{% if moment(profile.person.birthDate).diff(moment(), 'days') <= 30 %}

  {"content_id": "sample", "name": "{{profile.person.name.firstName}}"}

{% endif %}

In the above, moment(profile.person.birthDate) creates a moment object from the birthdate, and moment() creates a moment object for the current time. The diff method calculates the difference in days between the two moments. If the difference is less than or equal to 30, the JSON object is output with the person's first name.

Note that you may need to adjust the syntax and formatting depending on the specific JSON library or template engine you are using.

 

원본 게시물의 솔루션 보기

2 답변 개

Avatar

Community Advisor

Can you try this to see if that works,

 

{%#if (profile.person.birthDate.getDayOfYear() - now.getDayOfYear() <= 30) and (profile.person.birthDate.getDayOfYear() - now.getDayOfYear() >= 0) %}

{{profile.person.name.lastName}}

{%/if%}

Thanks, Sathees

Avatar

정확한 답변 작성자:
Employee Advisor

@gengaipandi11 ,

To compare dates in JSON & to check if the birthdate occurs less or greater than xx days after today, you can use-

{% if moment(profile.person.birthDate).diff(moment(), 'days') <= 30 %}

  {"content_id": "sample", "name": "{{profile.person.name.firstName}}"}

{% endif %}

In the above, moment(profile.person.birthDate) creates a moment object from the birthdate, and moment() creates a moment object for the current time. The diff method calculates the difference in days between the two moments. If the difference is less than or equal to 30, the JSON object is output with the person's first name.

Note that you may need to adjust the syntax and formatting depending on the specific JSON library or template engine you are using.