Find Rows Beween 2 Dates In TSQL

The following code will select rows between 2 dates in TSQL:

SELECT BusinessEntityID, RateChangeDate

FROM HumanResources.EmployeePayHistory

WHERE RateChangeDate BETWEEN '20011212' AND '20020105';

If just dates are specified, the time starts at 12:00AM. This means rows 12:01 AM or after on 01/05/2018 would not be included.

Helpful related links: