String was not recognized as a valid DateTime error even after using DateTime.ParseExact

Hi

Welcome to UiPath forum

Try with this expression

Datatime.ParseExact(strinput.ToString.SubString(0,10).Trim, “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture)

Output will be of DateTime

If you need in string of specific format

Stroutput = Datatime.ParseExact(strinput.ToString.SubString(0,10).Trim, “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

I want to suggest you one thing

You are almost right…

The only thing is timestamp

It’s in 24 hours format then hours should be in HH
But you have mention as hh in that DateTime expression

Change it to HH and give a try or
Try with the above suggestion

It should be fine

For more details on DateTime in UiPath

Cheers @Nikhil_kathpalia

2 Likes