| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: date and time comparision, calculauion
John Remus wrote:
>
> I like to select a date(time) type column and restrict it for example
> between 20:00 and 7:00.
It'fairly straightforward. Just remember to compare like datatypes.
SQL> col date_time format a20; SQL> col secs format 99990; SQL> SQL> SQL> select id 2 ,to_char(edate,'dd-Mon-yyyy hh24:mi:ss') date_time 3 ,to_number(to_char(edate,'sssss')) secs4 from temp
ID DATE_TIME
SECS
-------- --------------------
------
7698 02-Jan-1997 13:30:27
48627
7844 02-Jan-1997 14:31:46
52306
7566 03-Jan-1997 01:50:19
6619
7934 03-Jan-1997 09:03:28
32608
7654 04-Jan-1997 00:00:00
0
SQL>
SQL>
SQL> Rem
SQL> Rem Partial date comaprison (ignore seconds)
SQL> Rem
ID
DATE_TIME
--------
--------------------
7698 02-Jan-1997
13:30:27
7844 02-Jan-1997
14:31:46
SQL>
SQL>
SQL> Rem
SQL> Rem Or you can do a full numeric comparison
SQL> Rem
5 and 60*(60*14+31)6 order by edate
ID
DATE_TIME
--------
--------------------
7698 02-Jan-1997
13:30:27
SQL>
Hope this helps.
Chrysalis. Received on Wed Feb 26 1997 - 00:00:00 CST
![]() |
![]() |