SOLVED

Format Date Token

Go to solution
Trinity_Levens3
Level 3

Format Date Token

Hi, I need to change the standard date format from:  2017-02-27  to  27 February 2017   for an email send to a list of leads with a specific date for each. 

I'm using a token for a Contract Date field:  {{lead.Contract Date}} which produces the standard format 2017-02-27

The date in the lead record for the Contact Date field begins like this: Feb 27, 2017

Reading throughout the community on how to fix this and it's not as clear as I'd like but nonetheless I'm reaching out to see if there's a clear-cut answer as to how to code the velocity script and step by step instructions so it works.  I understand I can use a My.token at the program level and code it in velocity script, but from there I need more guidance.    Thanks!   -T

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Format Date Token

What time zone are those dates in (yes, this is an important detail when converting)?

View solution in original post

17 REPLIES 17
SanfordWhiteman
Level 10 - Community Moderator

Re: Format Date Token

What time zone are those dates in (yes, this is an important detail when converting)?

Trinity_Levens3
Level 3

Re: Format Date Token

Central Standard Time

Grégoire_Miche2
Level 10

Re: Format Date Token

Trinity_Levens3
Level 3

Re: Format Date Token

Checking out these links, Yes the time zone is important as I'm reading what Sanford said and going to attempt to fix this myself based off the similar conversation another lady had, but my client is asking that I spell out the month...that seems a bit more involved, is there additional code to render each unique month into it's corresponding word?    Many Thanks!!!

SanfordWhiteman
Level 10 - Community Moderator

Re: Format Date Token

Date format macro for the full month is MMMM. Thus when outputting the date/calendar object $contractDate:

${date.format("d MMMM yyyy",$contractDate)}

Trinity_Levens3
Level 3

Re: Format Date Token

Ok thank you I just tried the other way from the third link that Greg provided and it worked!!

Monday, February 27, 2017

I'm going to try this new code you just provided but I think my internal client will accept either option, thanks to you both, always appreciated how helpful and quick you are!!!

Trinity_Levens3
Level 3

Re: Format Date Token

Sanford Whiteman​  I tried replacing the last line of code with this:

${date.format("d MMMM yyyy",$contractDate)} 

But it rendered incorrect: ${date.format("d MMMM yyyy",$contractDate)} , and I'm too curious not to understand my mistake, what did I do wrong?

SanfordWhiteman
Level 10 - Community Moderator

Re: Format Date Token

Probably because you aren't using the variable name  $contractDate. You'd replace that with the actual variable name declared earlier in your code.

Trinity_Levens3
Level 3

Re: Format Date Token

Hmm sorry Sanford not sure about that, I'm still learning and I tried something and it didn't work, thus I keep trying