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 2008 Forums
 Transact-SQL (2008)
 check user supplied date range is between

Author  Topic 

rahulpatel112
Starting Member

4 Posts

Posted - 2012-05-03 : 03:22:12

Hello friends,

I need query which will check user supplied date range is in between the existing table startdate and enddate.
if any of the date of user supplied date range is in between the tables start date and end date,it should retrun that record from table.

for example user supply date range is from 1 may 2012 to 5 may 2012.
then query must check that
1 may 2005
2 may 2005
3 may 2005
4 may 2005
5 may 2005
(all dates) is in between startdate and enddate of existing table.

please reply...Thanx in advance

R.J.PATEL

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-03 : 03:48:47
SELECT * FROM dbo.Table1 WHERE DateColumnInTable BETWEEN @FromDate AND @ToDate


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -