Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

Reformatting date field in expression editor

Avatar

Level 1

Hi,

 

How can I reformat a standard date type field in the expression editor in ACS as follows:

From dd/mm/yyyy (standard date format in in ACS) to f.e. ddmmyyyy or dd.mm.yyyy

 

Does anyone have the same problem or a solution?

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi Roger, 

 

To do this, you would have to first transform the day/month/year values into string type after isolating them. 

 

The below expression outputs the date as numbers, and then transforms them into a string value so that you can set the separator to whatever you want: 

 

ToString(Day(@created)) + " " + ToString(Month(@created)) + " " + ToString(Year(@created))

 

In this case, you can replace the " " with a "." or take it out if you don't want any separators. If you want to always have the day and month value be represented as a two digit value, you'll have to include some if conditions to check whether a number is a single digit, and then append a 0 in front as I've done in the below expression:

 

Iif(Day(@created) > 9 , ToString(Day(@created)), "0" + ToString(Day(@created))) + " " + Iif(Month(@created) > 9 , ToString(Month(@created)), "0" + ToString(Month(@created))) + " " + ToString(Year(@created) )

 

It basically just checks if the month is greater than 9 e.g. 10+, return the value of month created as a string type, otherwise append a 0 in front and then return it as a string type. 

 

Cheers,

Jamal

View solution in original post

2 Replies

Avatar

Correct answer by
Level 2

Hi Roger, 

 

To do this, you would have to first transform the day/month/year values into string type after isolating them. 

 

The below expression outputs the date as numbers, and then transforms them into a string value so that you can set the separator to whatever you want: 

 

ToString(Day(@created)) + " " + ToString(Month(@created)) + " " + ToString(Year(@created))

 

In this case, you can replace the " " with a "." or take it out if you don't want any separators. If you want to always have the day and month value be represented as a two digit value, you'll have to include some if conditions to check whether a number is a single digit, and then append a 0 in front as I've done in the below expression:

 

Iif(Day(@created) > 9 , ToString(Day(@created)), "0" + ToString(Day(@created))) + " " + Iif(Month(@created) > 9 , ToString(Month(@created)), "0" + ToString(Month(@created))) + " " + ToString(Year(@created) )

 

It basically just checks if the month is greater than 9 e.g. 10+, return the value of month created as a string type, otherwise append a 0 in front and then return it as a string type. 

 

Cheers,

Jamal

Avatar

Level 1

Hi Jamal

 

Thanks a lot for your help! Your solution has worked!

 

Regards

Roger