Re: How to parse a string to datetime without a time

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> schreef in bericht news:op.udqd1req8jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
On Thu, 03 Jul 2008 12:14:52 -0700, Arjen <boah123@xxxxxxxxxxx> wrote:

I have a string with this value 07/11/2008. As you see no time included.

How can I parse this string to a datetime variable? I tried to do this but I get the exception that the format is incorrect.

Did you try the ParseExact() method? I would expect that to work fine.

I tried this but it did not work.
DateTime.ParseExact(Request.Form["date"], @"MM\/dd\/YYYY", null);

.



Relevant Pages

  • US vs UK datetime/string format failing on certain machines. Ideas
    ... I have a webform with a text box and a calendar control. ... or 6 lines of code just to format something from a text box ... String was not recognized as a valid DateTime. ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Why does this cause an error? (2005)
    ... The datatype in Sql Server is varchar, ... I'm using a procedure to format the number as follows: ... This flies but produces a "first chance exception" that "Input string ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Safe conversion from string to DateTime
    ... I have tried DateTime.Parse but it threw an exception on "12 noon". ... > Parse ignores leading and trailing white space, ... > DateTime.Parse will parse a valid date and time from a string. ... > match the format that you specify in the IFormatProvider parameter. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to parse a string to datetime without a time
    ... How can I parse this string to a datetime variable? ... I tried to do this but I get the exception that the format is incorrect. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Cant convert string to double!
    ... That prevents the code from causing an exception, but it doesn't solve the actual problem, which is the number format used to parse the string. ... John Fullmer wrote: ...
    (microsoft.public.dotnet.languages.csharp)