|
Posted by Aaron on 07/12/07 22:39
I was trying to retrieve all the records from a table, Crates that
fall within a particular date range for the field ShipDate, which is
of type datetime. What I have noticed is that the lower bound is
inclusive while the upper bound is not. For example, in this query, I
have noticed that ship dates from 4/5/07 to 4/17/07 are included while
ship dates from 4/18/07 are not:
SELECT *
FROM Crates
WHERE (ShipDate IS NOT NULL) AND (ShipDate > '4/5/07') AND
(ShipDate < '4/18/07')
ORDER BY ShipDate
I have also found that substiting > for >= and < for <= returns the
exact same results. One solution would be to increase the upper bound
by one day. However, I still find this strange. Is there a optimal
way for dealing with date ranges with SQL Server 2005.
Thanks,
Aaron
Navigation:
[Reply to this message]
|