Datetime change error in Automation anywhere

727 Views Asked by At

I'm trying to convert the date format from yyyy/MM/dd to dd/MM/yyyy. The year and month are getting changed without error but the value of date is different, like if the original date is 1992/12/02, it is getting converted as 334/12/1992. Any insight on this will be helpful.

1

There are 1 best solutions below

1
uozcan12 On
import datetime
sample_date = "1992/12/02"
sample_date = datetime.datetime.strptime(sample_date, "%Y/%m/%d").strftime("%Y/%d/%m")
print(sample_date)

Output:

1992/02/12