.Net DateTime type and SQL DateTime type
From: Matthias S. (postamt_at_emvoidSPAMTRAP.de)
Date: 09/02/04
- Next message: Richard J: "RE: primary key question"
- Previous message: Nitin Rana: "Re: check which field is updated"
- Next in thread: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- Reply: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- Reply: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 02 Sep 2004 19:31:16 +0200
Hi there,
I'm writing a C# application and using a C#Express Beta2 and SQLExpress
Beta2:
I've created an object (say 'Human') which I persist to a SQL DB table.
Human has a DateOfBirth property of the (.Net) type DateTime. The
apropriate field in the table is of SQL type DateTime. Now I create an
instance of my Human and set the DateOfBirth to yesterday using the
following code:
Human Human1 = new Human();
Human1.DateOfBirth = new DateTime.Now.Substract(new TimeSpan(1, 0, 0, 0));
Then that I persist my you Human to the database. After that I create a
new instance of my Human (Human2) and read it's property-values from the
database, like:
if(Human1.DateOfBirth == Human2.DateOfBirth) {
// this code is never reached :)
}
Comparing Human1's DateOfBirth with Human2's I do not get the expected
result as the two DateTime objects return the same Date and Time, but
looking at the DateTime.Tick property I see some fractional differences :).
How do you handle this? Thanks in advance.
Matthias
- Next message: Richard J: "RE: primary key question"
- Previous message: Nitin Rana: "Re: check which field is updated"
- Next in thread: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- Reply: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- Reply: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|