How can i convert any date format to "dd/mm/yyyy"

i get multiple dates i different formats,
dd-mm-yyyy
dd.mm.yyyy
01-apr-2020
but they all need to be in the same format
dd/mm/yyy

is there a code to change them all the that format?

2 Likes

@Rowley101, Convert the String to Date using CDate.

Then you can modify that converted date to your required format.
Eg. CDate(< String Var >).toString(“dd/MM/yyyy”)

3 Likes

Hi,

This is FYI. As UiPath handles datetime as InvariantCulture, the following result won’t be same.

CDate("05-06-2021").ToString("dd/MM/yyyy")

returns 06/05/2021

DateTime.ParseExact("05-06-2021","dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

returns 05/06/2021

If you need to prevent the above, set the following expression using Assign

System.Globalization.CultureInfo.CurrentCulture = New CultureInfo("es-ES")

img20211012-9

Regards,

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.