SOLVED

Velocity script value range/"between" operator

Go to solution
Megan_Koelemay
Level 4

Velocity script value range/"between" operator

I'm using a Velocity script to personalize content in my email that says Member since: XXXX where XXXX=year.  Currently, I'm hiding Member since: XXXX for anything earlier than 2007.  How do I adjust this to also hide anything later than 2020?  In other words, I only want to show the content if the year is between 2007 and 2020.

 

 

#if ( $convert.toNumber($lead.HCMemberSince) >= 2007 ) 
Member since: ${lead.HCMemberSince}
#end

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script value range/"between" operator

No need for anything special, just the && (AND) operator:

#set( $HCMemberSince = $convert.toNumber($lead.HCMemberSince) )
#if ( $HCMemberSince >= 2007 && $HCMemberSince <= 2020 ) 
Member since: ${HCMemberSince}
#end

 

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script value range/"between" operator

No need for anything special, just the && (AND) operator:

#set( $HCMemberSince = $convert.toNumber($lead.HCMemberSince) )
#if ( $HCMemberSince >= 2007 && $HCMemberSince <= 2020 ) 
Member since: ${HCMemberSince}
#end

 

Megan_Koelemay
Level 4

Re: Velocity script value range/"between" operator

Works beautifully - thank you, @SanfordWhiteman!