I'm pretty new to SQL SERVER and I'm trying to make some select with dates.
Table Dates
StartDate | EndDate |
05/01/2021 |
10/01/2021 |
20/01/2021 |
25/01/2021 |
There are 2 DATETIME pickers that the user can choose for
I would like to ask --> If a user picks StartDate 06/01/2021 and EndDate 08/01/2021
how could i know that they are not available days because I already have 05/01/2021 to 10/01/2021.
Here is what I tryied
SELECT * FROM MyDB.dbo.Dates WHERE CAST([StartDate] as date) >= '06/01/2021' AND
CAST([EndDate] as date) <= '08/01/2021'
But I get 0 records because I didn't write it good I guess, if someone could help me to think of about it would be very appreciated (if you find something missing I would be happy to help).
Thank you