Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: getting records for 1 day
"Paul Lautman" <paul.lautman_at_btinternet.com> wrote in message
news:5p5r0uFpgjp6U1_at_mid.individual.net...
> Summercool wrote:
>> in SQL, i wonder if I do a
>>
>>
>> select * from tablefoo where add_date = "2007-11-01"
>>
>>
>> then it may not show any record as it will only match recorded added
>> exactly at 2007-11-01 00:00:00
> Only if add_date is a DATETIME or TIMESTAMP type of field as oposed to a
> DATE type.
>
>
Many possibilities...
I always add a indexed DateID column that holds a FK to my Dates table. An integer lookup will always be faster.
or
You could add (and index) a column that holds only the date portion of the datetime field. There are many ways to truncate the time portion, I use convert(datetime,convert(varchar(50),add_date,101))
or
You could use ...BETWEEN '2007-11-01' AND '2007-11-02' Received on Sun Nov 04 2007 - 07:06:09 CST