HOW TO FIX BELOW ERROR

Error(Assign: The string ‘MM-dd-yyyy’ was not recognized as a valid DateTime. There is an unknown word starting at index ‘0’). There is no extra character before or after the date. But still not able to parse when trying to get from Excel.

Hi @Raghuveer_M

Could you try with the below one.

The value in the excel is in ‘MM-dd-yyyy’ this format but in string datatype. Use the below expression in assign activity and initialize it in a datetime datatype variable.

- Assign -> DateTime = DateTime.ParseExact(strStartDate,“MM-dd-yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString("MM-dd-yyyy")

Note - DateTime is a variable in datetime datatype.

Hope it helps!!

@Raghuveer_M

Looks like you string is not a date but a dateformat…like MM-dd-yyyy …please check the same

Cheers

Use Log Message to see the actual value you’re trying to parse. Post it here. Are you using Parse or ParseExact? Give us more info, details, show your code, etc so we can actually help.

Thank you Sir, The FirstAid tutorial helped me fix the error.

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