Date & time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • [Yosi]

    #1

    Date & time




    DateTime dd = DateTime.ParseE xact
    ("27/09/2003", "dd/MM/yyyy");

    I still get an error :
    "(939): No overload for method 'ParseExact' takes '2'
    arguments"

    [color=blue]
    >-----Original Message-----
    >Dates of that format are ambiguous. It's probably trying[/color]
    to parse this as[color=blue]
    >MM/dd/yyyy. Clearly this specific date is dd/MM/yyyy but[/color]
    the parser doesn't[color=blue]
    >try to figure that out. You can use DateTime.ParseE xact,[/color]
    e.g.[color=blue]
    >
    >DateTime dd = DateTime.ParseE xact[/color]
    ("27/09/2003", "dd/MM/yyyy");[color=blue]
    >
    >See the documentation for DateTime.Parse to see some[/color]
    more flexible examples[color=blue]
    >of how to do this without explicitly specifying the[/color]
    format.[color=blue]
    >
    >
    >"Yosi" <yousef_kh@hotm ail.com> wrote in message
    >news:11e001c38 530$025d9e00$a0 01280a@phx.gbl. ..[/color]

    Why i cann't convert date to DateTime :
    System.DateTime dd= Convert.ToDateT ime("27/09/2003");
    How to do that , tjis one thowes an exception .

    I can't find a Date class



  • Jon Skeet

    #2
    Re: Date &amp; time

    [Yosi] <yousef_kh@hotm ail.com> wrote:[color=blue]
    > DateTime dd = DateTime.ParseE xact
    > ("27/09/2003", "dd/MM/yyyy");
    >
    > I still get an error :
    > "(939): No overload for method 'ParseExact' takes '2'
    > arguments"[/color]

    As suggested before, look up DateTime.ParseE xact in the documentation.

    You'll find it takes either three or four parameters. You probably want
    the version taking three - there are examples in the MSDN for what you
    might want to use.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Bret Mulvey

      #3
      Re: Date &amp; time

      Sorry, forgot the IFormatProvider parameter:

      DateTime dd = DateTime.ParseE xact("27/09/2003", "dd/MM/yyyy", null);


      "[Yosi]" <yousef_kh@hotm ail.com> wrote in message
      news:10d501c385 9c$7f84d530$a10 1280a@phx.gbl.. .[color=blue]
      >
      >
      >
      > DateTime dd = DateTime.ParseE xact
      > ("27/09/2003", "dd/MM/yyyy");
      >
      > I still get an error :
      > "(939): No overload for method 'ParseExact' takes '2'
      > arguments"
      >
      >[color=green]
      > >-----Original Message-----
      > >Dates of that format are ambiguous. It's probably trying[/color]
      > to parse this as[color=green]
      > >MM/dd/yyyy. Clearly this specific date is dd/MM/yyyy but[/color]
      > the parser doesn't[color=green]
      > >try to figure that out. You can use DateTime.ParseE xact,[/color]
      > e.g.[color=green]
      > >
      > >DateTime dd = DateTime.ParseE xact[/color]
      > ("27/09/2003", "dd/MM/yyyy");[color=green]
      > >
      > >See the documentation for DateTime.Parse to see some[/color]
      > more flexible examples[color=green]
      > >of how to do this without explicitly specifying the[/color]
      > format.[color=green]
      > >
      > >
      > >"Yosi" <yousef_kh@hotm ail.com> wrote in message
      > >news:11e001c38 530$025d9e00$a0 01280a@phx.gbl. ..[/color]
      >
      > Why i cann't convert date to DateTime :
      > System.DateTime dd= Convert.ToDateT ime("27/09/2003");
      > How to do that , tjis one thowes an exception .
      >
      > I can't find a Date class
      >
      >
      >[/color]


      Comment

      Working...