Re: .Net DateTime type and SQL DateTime type
From: Steve Kass (skass_at_drew.edu)
Date: 09/02/04
- Next message: Patrick: "Re: export to excle"
- Previous message: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- In reply to: Matthias S.: ".Net DateTime type and SQL DateTime type"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Next message: Patrick: "Re: export to excle"
- Previous message: Steve Kass: "Re: .Net DateTime type and SQL DateTime type"
- In reply to: Matthias S.: ".Net DateTime type and SQL DateTime type"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|