Skip to main content
Level 2
Aug 3, 2022 9:48 AM UTC
Solved

How to use FlowBoost to compare a datetime field with ({{system.dateTime}} - 7 days) ?

I have a custom field called "Last Email Click Date" which is populated everytime a email click is triggered.

I want to do a check using FlowBoost if this date is a week ago, two weeks ago, one month ago etc so that I can do a time decay of the score accordingly.

 

logic is this.

Date1 = {{system.dateTime}} - 7 days

Date2 = {{system.dateTime}} - 30 days

CheckDate = {{lead.Last Email Click Date}}

 

if (Date1 > Check Date)

TimeDecay = -5;

elseif (Date2 > Check Date)

TimeDecay = -10;

else

TimeDecay = 0;

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Aug 3, 2022 2:25 PM UTC

 

const timeZone = "America/New York"; let now = FBUtil.time().tz(timeZone); let emailClickDate = FBUtil.time({{Lead.Last Email Click Date}}).tz(timeZone); var diffDays = emailClickDate.diff(now,"days");

 

 

This will set diffDays to the number of days between your Last Email Click Date and today. For example, if Last Email Click Date is 2022-07-07 then today (2022-08-03) diffDays is -27.

 

Then check if diffDays is in certain ranges:

if( diffDays < -30 ) { // last email clicked was more than 30 days ago } else if( diffDays < -7 ) { // last email clicked was more than 7 days ago but within the past 30 days } else if( diffDays < 0 ) { // last email clicked was before today but within the past 7 days }

 

(N.B. In this particular case you could leave off the time zones and get the same result, but it’s best practice to stay time zone-aware.)

1 reply

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Aug 3, 2022 2:25 PM UTC

 

const timeZone = "America/New York"; let now = FBUtil.time().tz(timeZone); let emailClickDate = FBUtil.time({{Lead.Last Email Click Date}}).tz(timeZone); var diffDays = emailClickDate.diff(now,"days");

 

 

This will set diffDays to the number of days between your Last Email Click Date and today. For example, if Last Email Click Date is 2022-07-07 then today (2022-08-03) diffDays is -27.

 

Then check if diffDays is in certain ranges:

if( diffDays < -30 ) { // last email clicked was more than 30 days ago } else if( diffDays < -7 ) { // last email clicked was more than 7 days ago but within the past 30 days } else if( diffDays < 0 ) { // last email clicked was before today but within the past 7 days }

 

(N.B. In this particular case you could leave off the time zones and get the same result, but it’s best practice to stay time zone-aware.)

Translate