Re: SQL:comparison using between
From: Garry M. Filimonov <garry_at_fly.triniti.troitsk.ru>
Date: 1996/08/14
Message-ID: <3211E5AE.18A2_at_fly.triniti.troitsk.ru>#1/1
Date: 1996/08/14
Message-ID: <3211E5AE.18A2_at_fly.triniti.troitsk.ru>#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!
'M...' <= X <= 'J...' -> nothing selected, besause 'M'>'J'
Use better:
select description,month,day,year from deadline where to_date(month||'-'||day||'-'||year,'MON-DD-YY') between to_date('MAR-08-96','MON-DD-YY') andto_date('JAN-01-97','MON-DD-YY');
Bye!
NastyNatal. Received on Wed Aug 14 1996 - 00:00:00 CEST