Question: I am looking to retrieve all records which `myDate` is between the `startDate` and 'endDate', but do not return records with exactly the same date. I am using MS SQL 2005.

I have tried:

`Select *`  

`From myDatabase`  

`Where empId = 145`  

`and myDate between startDate and endDate`

But if myDate was '11/16/2011' the above query would return records which have a `startDate` and `endDate` = '11/16/2011' as well. This isn't what I want. I do not want records which have a `startDate` and `endDate` = `myDate`

So I tried:

`Select *`  

`From myDatabase`  

`Where empId = 145`  

`and myDate between startDate and endDate`  

`and (myDate <> startDate AND myDate <> endDate)`

Will this work for all cases?

Answer: 
a1ex07 is right in that this will work

`myDate > startDate AND myDate < endDate` 

If you insist on using `BETWEEN` then this will work also

~~`mydate BETWEEN startDate + INTERVAL 1 DAY AND endDate - INTERVAL 1 DAY`~~

**Edit**: Just saw the tags for SQL Server not MySQL so the above is for MySQL, the SQL Server equivalent is

`myDate BETWEEN DATEADD(DAY, 1, startDate) AND DATEADD(DAY, -1, endDate)`
`BETWEEN` uses `>=` and `<=`

You will just need to use `>` and `<` if you don't want it to match the end points.

```
SELECT *
FROM myDatabase
WHERE empId = 145
AND myDate>startDate and myDate<startDate;

```