Re: date/time field and its index

From: Michael Nolan <nolan_at_helios.unl.edu>
Date: 18 Sep 1994 05:15:37 GMT
Message-ID: <35gidp$ijc_at_crcnis1.unl.edu>


barry.roomberg_at_compudata.com (Barry Roomberg) writes:

:-> I have a field which I am storing the date and time.
:->
:-> How do I select all rows with today's date (ie disregard time)?
:-> If I do a to_date to strip out the time I loose the use of the index
:-> on the field.
 

:Try "date_field between trunc(sysdate) and trunc(sysdate+1)"

Um, I this will pick up records with tomorrow's date and a time of 00:00. (IE, trunc(sysdate+1) _is_ included in the between range, which includes both endpoints.)

"date_field >= trunc(sysdate) and date_field < trunc(sysdate+1)" would work, though.

---
Michael Nolan, Sysop for the DBMS RoundTable on GEnie
nolan_at_notes.tssi.com, dbms_at_genie.geis.com
(posted from nolan_at_helios.unl.edu)
Received on Sun Sep 18 1994 - 07:15:37 CEST

Original text of this message