-2

My date format is like dd/mm/yyyy. When i have tried to convert it to Datetime I get this error:

System.FormatException: Le DateTime représenté par la chaîne n'est pas pris en charge dans le calendrier System.Globalization.GregorianCalendar.

English error:

System.FormatException: The datetime represented by the string is not supported in the System.Globalization.GregorianCalendar calendar.

And the error source is:

devises2.date_observation = DateTime.ParseExact(elements[0],
                                           "dd/MM/yyyy",CultureInfo.InvariantCulture );

Can you help me please?

James Dev
  • 2,979
  • 1
  • 11
  • 16
mypeeka
  • 57
  • 2
  • 11

1 Answers1

0

In your title you mention Excel. If that is where that date value came from, try

devises2.date_observation = DateTime.FromOADate(elements[0]);

See MSDN

Hans Kesting
  • 38,117
  • 9
  • 79
  • 111