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
 General SQL Server Forums
 New to SQL Server Programming
 Between Two Dates

Author  Topic 

U A
Starting Member

11 Posts

Posted - 2010-12-22 : 07:02:15
i have three columns 1)personid, 2)start date and 3)end date

I have to check whether person id is already there between two dates
ie) projected_start_date and projected_end_date

please help regarding this

Thank You

U A

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-12-22 : 07:13:21
SELECT * FROM Table WHERE StartDate >= Projected_start_date AND EndDate <=Projected_end_Date

Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-12-22 : 07:20:20
And for partial presence...

SELECT PersonID, StartDate, EndDate FROM Table1
WHERE StartDate <= @EndDate AND EndDate >= @StartDate



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

- Advertisement -