SOLVED

Re: Velocity script to return the last two characters in a string

Go to solution
Katja_Keesom
Level 10 - Community Advisor + Adobe Champion

Velocity script to return the last two characters in a string

I have an existing lead field that contains the value for a specific month, presented as YYYY-MM.

From this, I want to set up a script token that only returns the value for the month, irrespective of which year is indicated. I have the section of script to translate the MM value into "January", but I am struggling to strip the year indicator from the original value.

I looked into substring and truncate options, but have not found a working solution.

 

Does anyone have a suggestion?

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script to return the last two characters in a string

#set( $dateObj = $convert.parseDate( $lead.yourField, "yyyy-MM" ) )
${date.format("MMMM", $dateObj, $convert.toLocale("nl_NL"))}

View solution in original post

3 REPLIES 3
Katja_Keesom
Level 10 - Community Advisor + Adobe Champion

Re: Velocity script to return the last two characters in a string

I just knew there had to be a @SanfordWhiteman post out there somewhere that would help, and indeed!

Got there most of the way with the solution in this post: https://nation.marketo.com/t5/Product-Discussions/How-do-I-modify-the-date-format-for-a-token-using-...

Now just looking for a way to represent the MMMM in nl_NL locale so it shows the Dutch version of "January".

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script to return the last two characters in a string

#set( $dateObj = $convert.parseDate( $lead.yourField, "yyyy-MM" ) )
${date.format("MMMM", $dateObj, $convert.toLocale("nl_NL"))}
Katja_Keesom
Level 10 - Community Advisor + Adobe Champion

Re: Velocity script to return the last two characters in a string

Wow, I was overcomplicating again. Clean and effective.

Thank you!