Results 1 to 7 of 7

Thread: [RESOLVED] Weird String to Date error

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    55

    Resolved [RESOLVED] Weird String to Date error

    im using this to convert a date

    _dtestart = Date.Parse("20/04/2007")

    This gives no errors when testing the program on the device it , does so on the emulator , anyone know why ?

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Weird String to Date error

    Hi,
    take a look at the regional settings on the PC - my guess is they are set to US

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Weird String to Date error

    the best way to parse a date is to use yyyy/mm/dd as this does not cause a problem if you regional settings are set for having dates in the format dd/mm/yyyy
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    55

    Re: Weird String to Date error

    Well ive been using date.parseexact or , Cdate("") too , with every possible "dd/MM/yyyy" and stuff , but still no avail , constant format exception.

    As long as it works on the device im fine tho.

  5. #5
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Weird String to Date error

    _dtestart = Date.Parse("2007/04/20") should work everytime
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Weird String to Date error

    Have you checked out Pete's suggestion? I think you have a different regional setting on each one. That's a european style date, which won't do so well in a non-european setting.
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    55

    Re: Weird String to Date error

    Im dont have the rights to change regional settings so cant really try that out.
    But i think Pete's solution is the most viable , this computer is set with US settings the PDa is with European settings.

    thx

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