Insert month, based on dat field, into E-Mail

Avatar

Avatar
Validate 1
Level 1
roberts32477966
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
roberts32477966
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
roberts32477966
Level 1

01-09-2017

Hi all,

i would like to inster something like "September 2018" into an E-Mail. This should/could a personalization block or directly as personalization into the email. The month and year should based on a date field with the following format: 2017/08/31 00:00:00.

I guess putting an javascript for the calculation and the return, but I could not create the correct syntax.

Many thanks and br

Robert

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 5
Level 2
Pabst_dk
Level 2

Likes

11 likes

Total Posts

23 posts

Correct reply

4 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Validate 1
Boost 5
View profile

Avatar
Give Back 5
Level 2
Pabst_dk
Level 2

Likes

11 likes

Total Posts

23 posts

Correct reply

4 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Validate 1
Boost 5
View profile
Pabst_dk
Level 2

01-09-2017

Hi Robert,

You can use the following script to insert the date in the format you are looking for

<%

var monthNames = ["January", "February", "March", "April", "May", "June",  "July", "August", "September", "October", November", "December"];

var d = new Date();

document.write(monthNames[d.getMonth()] + " " + (d.getFullYear()));

%>

Hope this solves the issue you are facing,

Else please specify more narrow

Best Regards,

Jonas

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
Level 1
roberts32477966
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
roberts32477966
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
roberts32477966
Level 1

01-09-2017

Hi Jean, okay that sounds plausible. I will test it as well.

Avatar

Avatar
Validate 1
MVP
Jean-Serge_Biro
MVP

Likes

353 likes

Total Posts

464 posts

Correct reply

153 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Validate 1
MVP
Jean-Serge_Biro
MVP

Likes

353 likes

Total Posts

464 posts

Correct reply

153 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile
Jean-Serge_Biro
MVP

01-09-2017

Hi Roberts,

Alternative way to mention, please see the standard Adobe Campaign JSAPI function formatDate().
It is recommended over standard Javascript function, it eases date manipulation, especially timezone management, locale language and default format or specific format.

Examples:

ctx.vars.datetime_day = formatDate(getCurrentDate(),"%4Y-%2M-%2D %02H:%02N:%02S")

in your case, the format to use is:

"%Bl %4Y"

So in case of English language, it generates "September 2018", but in case of French, it generates "septembre 2018" (without Smart Capitalization) automatically.

Regards.

J-Serge

Avatar

Avatar
Validate 1
Level 1
roberts32477966
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
roberts32477966
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
roberts32477966
Level 1

01-09-2017

Wow great...fter I set an additional " n fornt of november it works many thanks for that fast help!