SOLVED

Re: Format Date Token

Go to solution
Trinity_Levens3
Level 3

Re: Format Date Token

Works great for this format:  Monday, February 27, 2017

#set( $inTimeZone = $date.getTimeZone().getTimeZone('America/Chicago') )  

#set( $outTimeZone = $date.getTimeZone().getTimeZone('America/Chicago') )  

#set( $locale = $date.getLocale() )  

#set( $myDate = $convert.parseDate($lead.contractDate,'yyyy-MM-dd',$locale,$inTimeZone) )  

${date.format('EEEE, MMMM dd, yyyy',$myDate,$locale,$outTimeZone)}

SanfordWhiteman
Level 10 - Community Moderator

Re: Format Date Token

Sure, that looks like my go-to code there.

The line that begins

${date.format(...

uses variables declared earlier ($myDate, $locale, etc.).

Trinity_Levens3
Level 3

Re: Format Date Token

Sanford Whiteman​   I'm getting a nasty error when I use this: pastedImage_0.png

Why can't I be as smart as you?!?!  I just want to know the answer!! 

#set( $inTimeZone = $date.getTimeZone().getTimeZone('America/Chicago') )  

#set( $outTimeZone = $date.getTimeZone().getTimeZone('America/Chicago') )  

#set( $locale = $date.getLocale() )  

#set( $myDate = $convert.parseDate($lead.contractDate,'yyyy-MM-dd',$locale,$inTimeZone)

${date.format('d MMMM yyyy',$myDate,$locale,$outTimeZone)}

SanfordWhiteman
Level 10 - Community Moderator

Re: Format Date Token

You put the code in an Email Script (Velocity) token, right?

Trinity_Levens3
Level 3

Re: Format Date Token

Hi Sanford,  Yes the velocity email script token was used, just replaced the code.  

SanfordWhiteman
Level 10 - Community Moderator

Re: Format Date Token

Can you show me a screenshot of the Email Script Editor with your code in it?

And you're sure (a) you have Contract Date selected in the right-hand tree and (b) that its VTL variable name is $lead.contractName? I would expect it to be $lead.Contract_Name given Velocity naming conventions.

Trinity_Levens3
Level 3

Re: Format Date Token

the Contract Date field value is:  ${lead.contractDate}

pastedImage_0.png

Trinity_Levens3
Level 3

Re: Format Date Token

this is the current script for this format:  Monday, February 27, 2017    I replaced the error script so that I can get this email out as it's a rush for today