Reformatting date field in expression editor | Community
Skip to main content
June 18, 2021
Solved

Reformatting date field in expression editor

  • June 18, 2021
  • 1 reply
  • 2300 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by jamal

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

1 reply

jamalAccepted solution
Level 2
June 21, 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

June 23, 2021

Hi Jamal

 

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

 

Regards

Roger