Click here to Skip to main content
15,903,385 members
Home / Discussions / C#
   

C#

 
General.Net DateTime type and SQL DateTime type Pin
matthias s.2-Sep-04 7:32
matthias s.2-Sep-04 7:32 
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 Smile | :) .

How do you handle this? Thanks in advance.

Matthias



If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)

www.emvoid.de

GeneralRe: .Net DateTime type and SQL DateTime type Pin
partyganger2-Sep-04 8:37
partyganger2-Sep-04 8:37 
GeneralRe: .Net DateTime type and SQL DateTime type Pin
Gary Thom2-Sep-04 8:54
Gary Thom2-Sep-04 8:54 
GeneralC# equivalent to CStringList Pin
Glenn E. Lanier II2-Sep-04 5:59
Glenn E. Lanier II2-Sep-04 5:59 
GeneralRe: C# equivalent to CStringList Pin
Werdna2-Sep-04 6:03
Werdna2-Sep-04 6:03 
GeneralRe: C# equivalent to CStringList Pin
Colin Angus Mackay2-Sep-04 6:04
Colin Angus Mackay2-Sep-04 6:04 
GeneralRe: C# equivalent to CStringList Pin
Glenn E. Lanier II2-Sep-04 6:27
Glenn E. Lanier II2-Sep-04 6:27 
GeneralRe: C# equivalent to CStringList Pin
Colin Angus Mackay2-Sep-04 6:04
Colin Angus Mackay2-Sep-04 6:04 
GeneralRe: C# equivalent to CStringList Pin
Glenn E. Lanier II2-Sep-04 6:28
Glenn E. Lanier II2-Sep-04 6:28 
GeneralRe: C# equivalent to CStringList Pin
Nick Parker2-Sep-04 9:31
protectorNick Parker2-Sep-04 9:31 
GeneralDos commands in C# Pin
exhaulted2-Sep-04 4:31
exhaulted2-Sep-04 4:31 
GeneralRe: Dos commands in C# Pin
mav.northwind2-Sep-04 5:36
mav.northwind2-Sep-04 5:36 
GeneralRe: Dos commands in C# Pin
exhaulted2-Sep-04 6:14
exhaulted2-Sep-04 6:14 
GeneralRe: Dos commands in C# Pin
mav.northwind2-Sep-04 6:28
mav.northwind2-Sep-04 6:28 
GeneralThe Infragistics Web Grid Big BIG problem Pin
Anonymous2-Sep-04 4:20
Anonymous2-Sep-04 4:20 
GeneralRe: The Infragistics Web Grid Big BIG problem Pin
Dave Kreskowiak2-Sep-04 5:50
mveDave Kreskowiak2-Sep-04 5:50 
GeneralDouble Buffering API Theme paint problem Pin
Tristan Rhodes2-Sep-04 1:52
Tristan Rhodes2-Sep-04 1:52 
GeneralRe: Double Buffering API Theme paint problem Pin
Werdna2-Sep-04 6:06
Werdna2-Sep-04 6:06 
GeneralRe: Double Buffering API Theme paint problem Pin
Tristan Rhodes2-Sep-04 8:59
Tristan Rhodes2-Sep-04 8:59 
Generalscroll bars in a picture box Pin
gijoebijoe2-Sep-04 1:30
gijoebijoe2-Sep-04 1:30 
GeneralRe: scroll bars in a picture box Pin
Sebastian Schneider2-Sep-04 2:27
Sebastian Schneider2-Sep-04 2:27 
GeneralRe: scroll bars in a picture box Pin
Sebastian Schneider2-Sep-04 2:37
Sebastian Schneider2-Sep-04 2:37 
GeneralMy images are gone (c#) Pin
adnanh752-Sep-04 0:42
adnanh752-Sep-04 0:42 
GeneralRe: My images are gone (c#) Pin
exhaulted2-Sep-04 1:47
exhaulted2-Sep-04 1:47 
GeneralRe: My images are gone (c#) Pin
adnanh752-Sep-04 1:53
adnanh752-Sep-04 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.