Error: String was not recognized as a valid DateTime


#1

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?


#2

For full control use datetime.parseexact


#3

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


#4

https://forum.uipath.com/t/string-with-date-into-date-format/5285


#5

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


#6

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”)