0

The code:

DateTime.ParseExact("2/2/2002", "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)

is raising System.FormatException.

I'll really appreciate if anybody could tell me what am I doing wrong.

John Woo
  • 258,903
  • 69
  • 498
  • 492
Amit Mittal
  • 1,129
  • 11
  • 30

1 Answers1

8

it should be d/M/yyyy

DateTime.ParseExact("2/2/2002", "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture)

the reason of exception is that it converts two places for dd but the string found is 2/.

John Woo
  • 258,903
  • 69
  • 498
  • 492