Question: I have a table with two DATETIME fields, OpeningDate and FinishingDate.

I am trying to write a query that returns all records that have a FinishingDate that is exactly 16 months ahead of the OpeningDate.

I know how to write the query to check between two dates (with SQL BETWEEN and DATEADD), but i'm not sure how to do this query. 

I have tried:

```
SELECT * FROM Sales
WHERE FinishingDate between OpeningDate AND DATEADD(MONTH, 16, OpeningDate)

```

But it appears to give me all records that fall between those dates, and not just those that are exactly 16 months ahead.

Any help would be great.

Thanks!

Answer: 
> 
> all records that have a FinishingDate that is exactly 16 months ahead
>  of the OpeningDate.
> 
> 
> 

I'm not fully certain, but this may not necessarily be to the exact day. If that's the case this would be the daterange greater than or equal to the first day of the 16th month and less than the first day of the 17th month.

```
SELECT * 
  FROM Sales
 WHERE FinishingDate >= --greater than or equal to start of 16th month
                        DATEADD(month, DATEDIFF(month, 0, DATEADD(MONTH, 16, OpeningDate)), 0)  
   AND FinishingDate < --less than the start of the 17th month
                        DATEADD(month, DATEDIFF(month, 0, DATEADD(MONTH, 16, OpeningDate)) + 1, 0)

```
My approach would be:

```
SELECT FinishingDate,OpeningDate FROM Sales
group by FinishingDate,OpeningDate
having DATEDIFF(m,OpeningDate,FinishingDate) >= 16

```