Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to Date constraint (Where clause)

Author  Topic 

geossl
Yak Posting Veteran

85 Posts

Posted - 2005-04-21 : 05:27:33
Dear All,
I am using a WHERE clause :
WHERE CreateDate BETWEEN '2005/3/1 0:0:0.0' AND '2005/3/1 23:59:59.999'

However, some records of 2005/3/2 are included in the result. What should be the best way to handle this situation?

Thanks.

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2005-04-21 : 05:40:27
SQL Server has 3.33 millisecond resolution... The date gets rounded up to the next date in your example...2005/3/1 23:59:59.998 will do the trick...

Run this in QA...

SELECT CAST('2005/3/1 23:59:59.999' as DATETIME)
SELECT CAST('2005/3/1 23:59:59.998' as DATETIME)


DavidM

A front-end is something that tries to violate a back-end.
Go to Top of Page
   

- Advertisement -