Is it possible to instruct DateTime.TryParseExact to accept multiple (any) sepatators (specify separator placeholder instead of particular separator)? For instance:
DateTime.TryParseExact(performanceRow[5], "M/d/yyyy",
CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out startDate)
This works if date has '/' character as separator. However I've just received a file with '.' as separator, and parsing fails.
Thanks
Use this variant of TryParseExact
DateTime.TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTime%)
MSDN link
The second param is a string array which is defined as
formats
Type: System.String[]
An array of allowable formats of s.
The description says: The format of the string representation must match at least one of the specified formats exactly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With