cancel
Showing results for 
Search instead for 
Did you mean: 

Need to change date format

MurugarajSa
Deputy Chef II
Deputy Chef II

Hi,

How do I change the date format from 02-Oct-23 to 02-10-2023.

Is there a way to achieve this by workato formula?

1 ACCEPTED SOLUTION

gary1
Executive Chef II
Executive Chef II

Ruby interprets "23" very literally, so it thinks the date is October 2 (day), 23 (year)

If all of your years are over 2000, you can do this:

 

"02-Oct-23".to_date + 2000.years ## outputs 2023-10-23

 

From there, you can do this:

 

[date].strftime("%d-%m-%Y") ## outputs "02-10-2023"

 

 This site is a great reference for using strftime to reformat dates: https://strftime.org/

View solution in original post

2 REPLIES 2

gary1
Executive Chef II
Executive Chef II

Ruby interprets "23" very literally, so it thinks the date is October 2 (day), 23 (year)

If all of your years are over 2000, you can do this:

 

"02-Oct-23".to_date + 2000.years ## outputs 2023-10-23

 

From there, you can do this:

 

[date].strftime("%d-%m-%Y") ## outputs "02-10-2023"

 

 This site is a great reference for using strftime to reformat dates: https://strftime.org/

It works perfectly. Thank you so much!