Date & time

Y

[Yosi]

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

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

-----Original Message-----
Dates of that format are ambiguous. It's probably trying to parse this as
MM/dd/yyyy. Clearly this specific date is dd/MM/yyyy but the parser doesn't
try to figure that out. You can use DateTime.ParseExact, e.g.

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

See the documentation for DateTime.Parse to see some more flexible examples
of how to do this without explicitly specifying the format.


news:[email protected]...

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

I can't find a Date class
 
J

Jon Skeet

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

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

As suggested before, look up DateTime.ParseExact 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.
 
B

Bret Mulvey

Sorry, forgot the IFormatProvider parameter:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top