I have a String was not recognized as a valid DateTime error.
Followed one of the examples from here. Which has an example that says:
dateString = "15/06/2008 08:30";
format = "g";
provider = new CultureInfo("fr-FR");
try {
result = DateTime.ParseExact(dateString, format, provider);
Console.WriteLine("{0} converts to {1}.", dateString, result.ToString());
}
catch (FormatException) {
Console.WriteLine("{0} is not in the correct format.", dateString);
}
Here's my code:
string convertToString = string.Join("", dateTimeId);
DateTime parsedDateTime = DateTime.ParseExact(convertToString, "g", CultureInfo.InvariantCulture);
I have a string array converted to string because I am reading one csv row which has a datetime value of "3/16/2002 9:20".
I also tried the format for "MM/dd/yyyy HH:mm", but still getting the same error.
Any tip or help is appreciated.