I have a query that should retrun the records of 'contacts' that will be a certain age within a specific date range.
Example: Gina will be 21 years old between 01/01/2016 and 01/01/2017 since she was born on: 1995-09-01 00:00:00.000
This is my query, for some reason returns no results even though I have the data above and those are my parameters.
SELECT b.FirstNm ,
b.UserId AS usercontid ,
c.FirstNm AS MainFirstNm ,
c.LastNm AS MainLastNm
FROM Users b
LEFT JOIN Partiescont AS a ON a.UserId = b.UserId
LEFT JOIN Users AS c ON c.UserId = a.PartcontId
WHERE 21 BETWEEN DATEDIFF(YEAR, b.DobD, 01 / 01 / 2016)
AND DATEDIFF(YEAR, b.DobD, 01 / 01 / 2017);
Any ideas ?