String was not recognized as a valid DateTime. dd-MM-yyyy to yyyy/MM/dd

I brought the date from the European website with Get text. I wanted to bring it as a DateTime type, but an error occurred that the date type was not available, so I brought it as a string type. Then, I tried all the codes below because I wanted to change the string type date to yyyy/MM/dd from dd-MM-yyy, but an error occurred.

DateTime.ParseExact(getEurDate, “dd-MM-yyyy”, CultureInfo.InvariantCulture).ToString(“yyyy/MM/dd”) = error
DateTime.ParseExact(getEurDate, “yyyy/MM/dd”, CultureInfo.InvariantCulture).ToString(“yyyy/MM/dd”) = error
DateTime.ParseExact(getEurDate.ToString, “dd-MM-yyyy”, CultureInfo.InvariantCulture).ToString(“yyyy/MM/dd”) = error
DateTime.ParseExact(getEurDate, “dd-MM-yyyy”, Nothing).ToString(“yyyy/MM/dd”) = error
DateTime.ParseExact(getEuroDate.ToString.Trim,“dd-MM-yyyy”,nothing).ToString(“yyyy/MM/dd”) = error

getEurDate.Trim.ToString(“yyyy/MM/dd”)

CDate(getEurDate).ToString(“yyyy/MM/dd”) = get error

It doesn’t matter what format this data is imported. I must change it to the yyyy/MM/dd string form.

Please help
Thank you

1 Like

use:
DateTime.ParseExact(getEuroDate.ToString.Trim({" ", vbNewLine, vbCr, vbLf}),“dd-MM-yyyy”,nothing).ToString(“yyyy/MM/dd”)

1 Like

still I get same error => String was not recognized as a valid DateTime.

Hi @rose.baek

DateTime.ParseExact(“Date”.ToString,“dd-MM-yyyy”, CultureInfo.InvariantCulture).toString(“yyyy/MM/dd”)

Please Try.

your variable getEuroDate have spaces and line breaks.
clean it.

DateTime.ParseExact(getEurDate.ToString, “dd-MM-yyyy”, CultureInfo.InvariantCulture).ToString(“yyyy/MM/dd”) = same error

Please find the Attached xaml

DateTime.ParseExact(date1.ToString,“dd-MM-yyyy”, CultureInfo.InvariantCulture).toString(“yyyy/MM/dd”)

This code works.

Please check if the mentioned input in your case “dd-MM-yyyy” is what’s the output of your Get text , kindly use a breakpoint after get text activity and check in immediate to confirm the output format.

Thanks.

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