egs..
select abc
from xyz, dual
where activitydate = sysdate
Why not ?
where mytable.start_date between sysdate and sysdate + 7
Regards,
Marc Mazerolle
Ehhh, why search for a start date from now, until 7x24 hours from now?
> > select abc
> > from xyz, dual
> > where activitydate = sysdate
where trunc(activitydate) = trunc(sysdate)
Arjan.
You don't need to join the dual table, and if you can, don't apply function
on column because if the column is indexed, Oracle will not use the
index,
so :
select abc
from xyz
where activitydate>=trunc(sysdate)
and activitydate < (trunc(sysdate+1))
Jerome.
I would follow Marc's advice for one reason : if activitydate is
indexed,
the otherwise perfectly valid trunc(activitydate) will prevent (unless
you are running Oracle 8.1 and have indexed trunc(activitydate)) using
the index.
--
Regards,
Stéphane Faroult
If you don't use trunc(..), like
select abc
from xyz
where activitydate>=sysdate
and activitydate < (sysdate+1)
then at 21:12 you'd only select activity dates between today, 9:12 p.m.
and
tomorrow, 9:12 p.m. I doubt that is what anyone would ever need....
Arjan.
Yes, you probably should use TRUNC. Remember that even though dates
in Oracle look like just plain old dates, internally they are
represented as a
real number and encodes time as well as the date into a date field.
The
trunc strips off the fractional values that represent the time to
effectively
convert the date field to a time of midnight. Play with TO_CHAR with
a format of hh24:mi:ss among other things to look at the time that
is
encoded with the date.
...Ru