Change Int to Datetime Variable

I have the integer 20231017 representing a date in the ‘yyyymmdd’ format without any special characters. I need to convert it into the ‘ddMMyyyy’ format. How can I do this in UiPath?

Assign input = “20231017”
Assign parsedDate = DateTime.ParseExact(input, “yyyyMMdd”, System.Globalization.CultureInfo.InvariantCulture)
Assign formattedDate = parsedDate.ToString(“ddMMyyyy”)

Hi,

FYI, another approach:

System.Text.RegularExpressions.Regex.Replace(intVar.ToString,"(\d{4})(\d{2})(\d{2})","$3$2$1")

Regards,

1 Like

Hi @Srushti_Swami

Welcome to the community !!

Try this way,

Datetime variable = DateTime.ParseExact("Yourinput.tostring.trim",{"yyyyMMdd"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None)

output variable str = Datetime variable.tostring(“ddMMyyyy”)

If you have more input format means you can add in the array

Regards,
Gowtham K

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