I have table called Master and i need all the possible records of all matching date as per user Input between @FromDate and @Todate....
Master Table:
ID FromDate ToDate
1 18/03/2014 18/03/2014
2 01/03/2014 05/03/2014
3 06/03/2014 08/03/2014
My Query:
select ID
from master M
where M.FromDate between('10/03/2014') and ('17/03/2014')
or M.ToDate between ('10/03/2014') and ('17/03/2014')
User Input:
FromDate ToDate
01/03/2014 06/03/2014
01/03/2014 31/03/2014
09/03/2014 09/03/2014
Expected Output:
2,3
1,2,3
No Records
I Got The Solution:
SELECT ID
FROM master M
WHERE ((M.FromDate BETWEEN '10/03/2014' AND '17/03/2014')
OR (M.ToDate BETWEEN '10/03/2014' AND '17/03/2014'))
parenthesis is Very Important in Sequel Server.....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With