CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2008
    Posts
    30

    DateTime.ParseExact

    Hi,
    I want to parse data in string to a particular datetime format so that i am trying to use
    DateTime.ParseExact ..

    DateTime dateTime ;
    DateTime.TryParseExact("10/20/2009", "dd/MM/yyyy", CultureInfo.InvariantCulture,DateTimeStyles.None, out dateTime);

    But i have got the following error
    " The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar"

    pls give a solution to parse the date..

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: DateTime.ParseExact

    Quote Originally Posted by meenus View Post
    Hi,
    DateTime dateTime ;
    DateTime.TryParseExact("10/20/2009", "dd/MM/yyyy", CultureInfo.InvariantCulture,DateTimeStyles.None, out dateTime);
    I think the problem is that you're specifying "20" as the value for "MM" or the month. The Gregorian Calendar only has 12 months. Try switching those values around e.g. "20/10/2009" or "MM/dd/yyyy"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured