Good point, @tim-khorev ! I’ve definitely run into issues when the Date
column has a time component (like 2011-02-25 14:30:00
). This can cause the query to miss records from the end date, because sql between dates
is inclusive, and it might not include records that fall on the exact end date but later in the day. Here’s how I usually work around that:
WHERE Date >= '2011-02-25' AND Date < '2011-02-28'
By changing the sql between dates
logic like this, you make sure that the entire day on the 27th is included, and you don’t need to worry about time precision. This is a cleaner approach when dealing with datetime columns where time matters.