Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Problem comparing dates
Rhugga wrote:
> I amtrying to select rows that fit a certain time period.
>
> My table:
> BCV_START DATE
> COL1 VARCAHR2
> COL2 VARCAHR2
>
> My data is inserted as follows:
>
> INSERT INTO MYTABLE VALUES ( to_date('2005-07-20 16:30:00', 'YYYY-MM-DD
> HH24:MI:SS', 'data', 'data')
>
> The following query is not behaving as expected:
>
> SELECT * FROM MYTABLE where to_date(bcv_start, 'DD-MON-YYYY HH24:MI') >
> to_date('20-JUL-2005 01:00', 'DD-MON-YYYY HH24:MI') AND
> to_date(bcv_start, 'DD-MON-YYYY HH24:MI') < to_date('20-JUL-2005
> 17:00', 'DD-MON-YYYY HH24:MI')
>
> What am I doing wrong here?
>
> Thx,
> CC
>
You should use it without to_date function around BCV_START.
(Maybe a little bit unclear expressed:
SELECT *
FROM MYTABLE
where
bcv_start > to_date('20-JUL-2005 01:00', 'DD-MON-YYYY HH24:MI') AND
bcv_start < to_date('20-JUL-2005 17:00', 'DD-MON-YYYY HH24:MI')
)
Best regards
Maxim Received on Thu Jul 21 2005 - 15:12:56 CDT
![]() |
![]() |