M
Matthias S.
Hi,
I create a DateTime object in C# like this...
DateTime _DateStart = new DateTime(2000, 1, 1, 1, 1, 1, 1);
Now I save it to the Database (into a DateTime type of column) using the
SqlCommand and later I reload the value. Comparing those using the == operator
of the DateTime object yields incorrect results. Say I have two DateTime
objects, one was loaded from the DB:
DateTime _DateLoaded = LoadTheDateFromTheDB();
DateTime _DateToCompareWith = new DateTime(2000, 1, 1, 1, 1, 1, 1);
if (_DateLoaded == _DateToCompareWith)
// unreachable code detected
)
Obviously, the Tick-Count is not equal. How do I get on about saving DateTime
values to a Database. Should I store the ticks instead of the dates? Am I
something missing about the DateTime object and its == operator?
In fact, I'm actually not even interested in the Milliseconds part (and
everything beyond that level of precision). I'd just like to compare two dates
based on their Date (DDMMYYYY) and their Time (HHMMSS) values.
Thanks for any help in advance!
I create a DateTime object in C# like this...
DateTime _DateStart = new DateTime(2000, 1, 1, 1, 1, 1, 1);
Now I save it to the Database (into a DateTime type of column) using the
SqlCommand and later I reload the value. Comparing those using the == operator
of the DateTime object yields incorrect results. Say I have two DateTime
objects, one was loaded from the DB:
DateTime _DateLoaded = LoadTheDateFromTheDB();
DateTime _DateToCompareWith = new DateTime(2000, 1, 1, 1, 1, 1, 1);
if (_DateLoaded == _DateToCompareWith)
// unreachable code detected

Obviously, the Tick-Count is not equal. How do I get on about saving DateTime
values to a Database. Should I store the ticks instead of the dates? Am I
something missing about the DateTime object and its == operator?
In fact, I'm actually not even interested in the Milliseconds part (and
everything beyond that level of precision). I'd just like to compare two dates
based on their Date (DDMMYYYY) and their Time (HHMMSS) values.
Thanks for any help in advance!