Reputation: 5259
I have to convert a date string to a DateTime object as follows
tmpdate = "27-Apr 14:53";
TheDate = DateTime.ParseExact(tmpdate, "DD-MMM HH:mm", CultureInfo.InvariantCulture);
I keep getting exceptions about the string not being a valid date time. I've tried adding in the year as well with no luck. Any suggestions?
Upvotes: 1
Views: 1448
Reputation: 15071
string tmpdate = "27-Apr 14:53";
DateTime TheDate = DateTime.ParseExact(tmpdate, "dd-MMM HH:mm", System.Globalization.CultureInfo.InvariantCulture);
Upvotes: 1
Reputation: 6851
try with little d :
TheDate = DateTime.ParseExact(tmpdate, "dd-MMM HH:mm", CultureInfo.InvariantCulture);
Upvotes: 1