Ask Your Question
2

What is the code in Adobe Journey Optimizer for formatting dates using PQL and JS?

asked 2023-07-11 01:21:37 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-11 01:38:02 +0000

huitzilopochtli gravatar image

To format dates using PQL and JS in Adobe Journey Optimizer, you can use the following code:

  1. PQL:
select format("my_date_field", "yyyy-MM-dd") as "formatted_date" from my_schema.my_table

This code will format the date in the "mydatefield" column of the "mytable" table in the "myschema" schema as "yyyy-MM-dd" and rename the formatted date as "formatted_date".

  1. JS:
var date = new Date("2022-02-20");
var formattedDate = date.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' });
console.log(formattedDate);

This code will format the date "2022-02-20" as "MM/dd/yyyy" using the toLocaleDateString() function and log it in the console. You can modify the function's parameters to format the date in different ways.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-11 01:21:37 +0000

Seen: 17 times

Last updated: Jul 11 '23