Re: SQL:comparison using between

From: Bob Morrison <rmorrison_at_cahners.com>
Date: 1996/08/14
Message-ID: <3212305E.1B28_at_cahners.com>#1/1


Hayashi! wrote:
>
> hi,
>
> I seem to have trouble figuring out the correct way of
> using BETWEEN. (for example:
>
> select description,month,day,year
> from deadline
> where (month||' '||day||' '||year)
> between ('MAR'||' '||'08'||' '||'96')
> and ('JAN'||' '||'01'||' '||'97');
>
> all it gives me as a result is "no rows selected" but that isn't true
> I'm not sure if I have written something incorrectly.
> hope someone could give me some suggestions as to overcome this problem
> Thanks!

The current SQL statement is doing character comparison not date comparision. You want:

select description,month,day,year
from deadline
where to_date(month||' '||day||' '||year,'mon dd yy'))

     between '08-mar-96' and '01-jan-97';

Bob Morrison Received on Wed Aug 14 1996 - 00:00:00 CEST

Original text of this message