You are here: Date Range for SQL 2005 « MsSQL Server « IT news, forums, messages
Date Range for SQL 2005

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация