Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL date inquiry
Alan D. Mills wrote:
>
> >
> >Time defaults to 12:00am for dates. If you have time, then you need
> >to check for the date being between date=> and <date +1.
> >
> >I've got a nasty looking algorythem that works. It converts date to
> >char adds 1, then converts back to date to do the arithmatic. I'd
> >love to see a simpler solution.
> >
>
> Make sure both sides of the comparison are both date format and then TRUNC
> both sides
>
> i.e. AND TRUNC(date1) = TRUNC(date2)
>
> This will be true if the days are the same regardless of times. It sames
> the date arithmetice (adding one) and an extra test.
And if you have an index on the date column to speed things along, once you apply a function to the column the index won't be used (IIRC). Something to bear in mind for the future...
Mungo Henning Received on Thu Sep 17 1998 - 08:23:00 CDT
![]() |
![]() |