Error: String was not recognized as a valid DateTime

Hi all,

The cell I am trying to read is “27.07.18” - i keep getting the same error, unless I change the format to “07.27.18”

What should i do?

For full control use datetime.parseexact

First try to read this as a string, next parse this as datetime format - datetime.parseexact(…)
IF you still receive error try to replace 18 with 2018 and try again

you can use .trim in the string
you can use there

Get your date from the excel as string and convert it as date in assign activity as below

Assign to a date variable: Convert.ToDateTime(dt.Rows(0)(“YourDate”).ToString).Date

Then while feeding it in your website convert your date as below

DateTime.ParseExact(convertedDate.ToString(“MM.dd.yyyy”), “MM.dd.yyyy”, Nothing).ToString(“dd-MM-yyyy”)


When I try to convert a string to a date time I get an error message “String was not recognized as a valid DateTime”. However this only happens when I get the data from a website using Get Text, if I populate the variable directly by typing in the exact same string into an AB Assign there is no issue when trying to convert.

The variable is 28/11/2018 and I am using DateTime.ParseExact(Variable.ToString(),“dd/MM/yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)



Hey @Shaun_Manuel , may be there are some spaces when you are getting data from web trim that string by adding .trim in its end and try once

Does uipath only allow one datetime format like day/month/year cos when i try to change the format to start with the year, " i get Message Box: String was not recognized as a valid DateTime."

Hello I am having the same problem even after I tried upper solutions.

  1. I make a string with
  2. then I make a date variable with parseexact using string made in step one
  3. then after I make a new string with datevariable.tostring

Please instantiate your datetime variable in variable default panel and try.

Like below:
Variable Name: datecurrentperson
Default Value: new DateTime()