Date conversion not working

I am trying to convert date yyyy-MM-dd HH:mm:ss to format MM/dd/yyy using datetime.parseexact(“2021-10-31 01:17:09”,“yyyy-MM-dd HH:mm:ss”, System.Globalization.Cultureinfo.InvariantCulture).Tostring(“MM/dd/yyyy”)
But getting error message string was not recognised as a valid date time.
How can I rectify this error. Please help


Welcome to our UiPath community.

Please try below expression.

     CDate("2021-10-31 01:17:09").ToString("MM/dd/yyyy")
1 Like


Your expression seems no problem as the following.

Can you try the following sample?

Sequence1.xaml (4.5 KB)


1 Like


Welcome to uipath forum

You are almost done

If the input variable of string named strinput is of this format

Then use a assign activity like this

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

Cheers @Rilna_Rilna

1 Like

It works now. Though not sure what was the mistake I did. Thanks

1 Like

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