Reputation: 846
I am getting this error: String was not recognized as a valid DateTime.
DateTime date = DateTime.ParseExact("4/29/2013", "MM/dd/yyyy", null);
Upvotes: 0
Views: 321
Reputation: 499132
Use one M
instead of MM
to match the format for months values that are one or two numbers.
The same goes for d
for days.
DateTime date = DateTime.ParseExact("4/29/2013", "M/dd/yyyy", null);
DateTime aDate = DateTime.ParseExact("4/2/2013", "M/d/yyyy", null);
Upvotes: 2