DateTime problem

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?
 
J

Jon Skeet [C# MVP]

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.
 
M

Morten Wennevik

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)
 
H

Hans Kesting

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
 
G

Guest

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.
 

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