Each on our team has their own method on extracting data between dates and we’ve come with two common methods of extracting data using:
- [DateTimeColumn]BETWEEN @StartDate AND @EndDate
- [DateTimeColumn] > @StartDate AND[DateTimeColumn] <= @EndDate
When to use/Difference “BETWEEN” and “> AND <=” on datetime : SQL Query Optimization and which of the two is the best to use.
BETWEENoperator uses inclusive ends of the interval. Use specific compare operations whenever you are looking to exclude one or both ends of the interval.Additionally,
BETWEENis convenient when you test against a complex expression: for example, writing something likeis easier than repeating the
CASEexpression twice.