May 4, 2006 at 7:26 am
This is not correct.
Using BETWEEN in this scenario will give you everything from midnight 2006-05-01 up to and including midnight 2006-05-02.
/Kenneth
May 4, 2006 at 10:12 pm
The following is wrong because it leaves out one entire second of the day...
BETWEEN '2006-05-01 00:00:00.000' AND '2006-05-01 23:59:59.000'
...depending on the source of the data, there could be thousands of records in that one second.
Kenneth is absolutely correct in implying that the other BETWEEN scenarios are wrong because if you have any date with "no times" from the next day, they will erroneously be included.
The proper way to do this and still have indexes kick in when available is...
WHERE somedatecolumn >= '2006-05-01'
AND somedatecolumn < '2006-05-02'
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply