Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone,
I need to make a stored procedure which returns the list of Employee Ids in the following scenario:
I have a table with following columns:
*EmployeeId *LeaveFromDate *LeaveToDate

I need a Proc which will return the collection of EmployeeId whose Leave Date Range intersect with each other.

e.g If EmployeeId = 1 has leave from 4 April to 7 April
and EmployeeId = 4 has leave from 6 April to 8 April
then my proc should return values 1,4 to me.

Please help!!
Regards
Lakshay Dulani
Posted

1 solution

Dear Friend,

I think the following query will work for you:-

select EmployeeId from Employee where LeaveFromDate between @FromDate and @ToDate


where @FromDate is 4 Apriland @ToDate is 7 April in your case.

Add the above query in the stored proc you make.

Thanks
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900