String was not recognized as valid Date Time

Hi Guys.

I am passing this ‘str_User_DepDate’(which holds the date read from excel) variable to another workflow, where the argument’s data type is ‘DateandTime’
and I have converted the string to date and time by using this ‘Convert.ToDateTime(str_User_DepDate)’ but I am getting this error stating;
“Invoke WebDataExtraction workflow: String ‘15/09/2022’ was not recognized as a valid DateTime.” Any idea on how to solve this?

Your help is much appreciated.

Regards
Chendoran

try this instead to convert your string to datetime

Datetime.parseExact(str_User_DepDate, "dd/MM/yyyy", nothing)

can you tell me bit are you trying to convert to other format?

DateTime.ParseExact(strIn, “dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

try this

Hi @Chendoran_M

Can you confirm that your passing str_User_DepDate from one workflow to another workflow correct?

If yes, What are the Variable and Argument type?

Regards
Gokul

The passing of the variable is correct. The variable is of type string and the argument is of type DateTime.

Change the Argument type to String and check it

Regards
Gokul

Hey!

Try this…

Datetime.ParseExact(Strinput.ToString, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Regards,
NaNi

Didn’t work. Got this error again,
System.FormatException: String ‘22/03/2023’ was not recognized as a valid DateTime.

This has worked. Thank you @jack.chan

1 Like

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