Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL2000 - Two different DateTime values return equal

Posted on 2006-07-11
4
Medium Priority
?
721 Views
Last Modified: 2008-01-09
Can anyone tell me why it is that Sql Server 2000 returns 1 on the this?:

Declare @firstDate DateTime
Select @firstdate = '6/15/2006'
Select 1 where '6/14/2006 23:59:59.999' = @firstDate

These are two separate DateTime values, but yet SQL Server 2000 seems to think they are equal... This threw a reporting query of mine off simply because the statement returns true in my match criteria.
0
Comment
Question by:Sean McIlvenna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 375 total points
ID: 17085719
Hi realevergod,

The datetime data type does not have the ability to resolve differences larger than 0.03 seconds, so
6/14/2006 23:59:59.999 rounds up to 6/15/2006 0:00:00

Regards,

Patrick
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 17085726
> resolve differences larger than 0.03 seconds

Sorry, meant SMALLER than :)

Regards,

Patrick
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17085733
I could reproduce your problem, I went even a step further (no solution):

Declare @firstDate DateTime
Select @firstdate = convert(datetime,'6/15/2006',101)
declare @lastdate datetime
select @lastdate = convert(datetime, '2006-06-14 23:59:59.999', 121)
Select 1 where @lastdate = @firstDate
select convert(varchar(30), @firstdate, 121), convert(varchar(30), @lastdate, 121)

Listening & Learning
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 17085739
realevergod,

Sorry, the smallest resolution is not 0.03 seconds, but rather 1/300th of a second, or about 0.00333 seconds.
But SQL Server still has to round yours up.

Regards,

Patrick
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question