โ10-27-2023 11:19 AM
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?
Solved! Go to Solution.
โ10-27-2023 11:54 AM - edited โ10-27-2023 11:55 AM
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/
โ10-27-2023 11:54 AM - edited โ10-27-2023 11:55 AM
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/
โ10-27-2023 10:17 PM
It works perfectly. Thank you so much!