MSSQLTips.com · January 08, 2025
Select SQL Server Data Between Two Dates
This tutorial compares methods for retrieving SQL Server records within a specified date or time range. Examples using StackOverflow2010 illustrate comparison operators, range predicates and the importance of distinguishing date boundaries from timestamps when defining the desired result set.
The discussion examines date-based partitioning and demonstrates how queries can target relevant partitions, including cases where a separate day-of-year column serves as the partition key. An example combines explicit partition selection with timestamp filters for the boundary days, illustrating how query design can reduce unnecessary data access in large partitioned tables.