DATE
is a reserved keyword in Oracle, so I'm using column-name your_date
instead.
If you have an index on your_date
, I would use
WHERE your_date >= TO_DATE('2010-08-03', 'YYYY-MM-DD')
AND your_date < TO_DATE('2010-08-04', 'YYYY-MM-DD')
or BETWEEN
:
WHERE your_date BETWEEN TO_DATE('2010-08-03', 'YYYY-MM-DD')
AND TO_DATE('2010-08-03 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
If there is no index or if there are not too many records
WHERE TRUNC(your_date) = TO_DATE('2010-08-03', 'YYYY-MM-DD')
should be sufficient. TRUNC
without parameter removes hours, minutes and seconds from a DATE
.
If performance really matters, consider putting a Function Based Index
on that column:
CREATE INDEX trunc_date_idx ON t1(TRUNC(your_date));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…