Reformatting date field in expression editor

Avatar

Avatar
Validate 1
Level 1
RogerScheidegger
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
RogerScheidegger
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

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

18-06-2021

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?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 3
Level 2
jamal
Level 2

Likes

6 likes

Total Posts

5 posts

Correct reply

3 solutions
Top badges earned
Affirm 3
Boost 5
Boost 3
Validate 1
Affirm 1
View profile

Avatar
Affirm 3
Level 2
jamal
Level 2

Likes

6 likes

Total Posts

5 posts

Correct reply

3 solutions
Top badges earned
Affirm 3
Boost 5
Boost 3
Validate 1
Affirm 1
View profile
jamal
Level 2

21-06-2021

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

Answers (0)