DateTime problem

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Hello.

I have some basic problem:
I want to assign to my DateTime object date and time, I wrote:
DateTime d;

d = DateTime.Parse("01/05/2004 10:00:00");

But it assigns only date part (not both date + time).

What I'm doing wrong?
 
Dave said:
I have some basic problem:
I want to assign to my DateTime object date and time, I wrote:
DateTime d;

d = DateTime.Parse("01/05/2004 10:00:00");

But it assigns only date part (not both date + time).

What I'm doing wrong?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Hi Dave,

I cannot verify your problem as DateTime.Parse("10/05/2004 10:00:00")
correctly parses as May 10th 2004 at 10:00:00 (dd/MM/yyyy)
 
Dave said:
Hello.

I have some basic problem:
I want to assign to my DateTime object date and time, I wrote:
DateTime d;

d = DateTime.Parse("01/05/2004 10:00:00");

But it assigns only date part (not both date + time).

What I'm doing wrong?

How do you know it assigns only the date? Are you maybe looking at
the tooltip from the debugger? That only *shows* the date-part!
Try to do a ToString() or get the Hour value.

By the way: your example date, is that "1st of May" or "5th of Jan"?


Hans Kesting
 
Also try changing your regional setting for date formate on your computer.
Though not in VS.Net/C#, but I have experienced this in other tools.
 
Back
Top