Re: .Net DateTime type and SQL DateTime type

From: Steve Kass (skass_at_drew.edu)
Date: 09/02/04


Date: Thu, 02 Sep 2004 13:46:14 -0400

Oops - I forgot where I was posting. For SQL Server 2005 questions, you
might wish to read and post to the semi-private newsgroups that have
been established for the beta version of that product
(http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us).

SK

Matthias S. wrote:

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



Relevant Pages

  • Re: MS Access DAO -> ADO.NET Migration
    ... William Vaughn ... Microsoft MVP ... Hitchhiker's Guide to Visual Studio and SQL Server ... My migration app works building a SSCE database file with imported data ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Cluster will not fail over.
    ... > As far as the TCP/IP issue goes, you had to rebuild the cluster and were ... > able to restore the master database. ... > a cluster installation you'll have to revisit. ... >> This worked bringing up the sql server in minimal mode. ...
    (microsoft.public.sqlserver.clustering)
  • Re: MS Access DAO -> ADO.NET Migration
    ... full SQL Server and I see the logic you explained in a multi user ... allow two users to access the same database file Read/Write at any given ... The book was a pleasure to read after the gibberish that Microsoft 'puts ... Hitchhiker's Guide to Visual Studio and SQL Server ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: MS Access DAO -> ADO.NET Migration
    ... For that it is much harder to handle the incremental identifier, ... database but although they have the data, they are not connected at the same ... The book was a pleasure to read after the gibberish that Microsoft 'puts ... SQL Server Management Studio is nowhere to be found on my ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Word 2003/Access2000/SQLSVR
    ... SQL server being where the data is held and this is accessed through a MS ... entire database and that may be say a record for Berkshire. ... "Peter Jamieson" wrote: ... replaced with the first record on the table in use. ...
    (microsoft.public.word.mailmerge.fields)

Loading