You can use TryParseExact
and specify your formats. There is an overload taking string[]
patterns array as a parameter:
DateTime.TryParseExact
Method (String
, String[]
, IFormatProvider
, DateTimeStyles
, DateTime
)
You can call it like that:
DateTime.TryParseExact(cell.ToString(), new [] { "M/d/yyyy", "hh:mm" }, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out _dt);
You may need Custom Date and Time Format Strings to prepare more patterns to make sure it works for all your input formats.