Eirikur Eiriksson - Sunday, November 12, 2017 2:57 AM
This will include records that you don't want to include. When using date ranges, you should be using half-closed intervals. Most people use closed intervals, but this goes to the other extreme and uses open intervals. Neither is correct for most uses. Specifically, this method will include dates between 2014-12-31 23:59:00.003 and 2014-12-31 23:59:59.997 that you do not want to include. The correct formulation is as follows.
WHERE [date] >= CAST('2015-01-01' AS DATETIME)
AND [date] < CAST('2016-01-01' AS DATETIME)
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA