Re: How extract time values from date fields?

From: Jurij Modic <jmodic_at_src.si>
Date: Fri, 15 Jan 1999 22:26:58 GMT
Message-ID: <369fc0a3.8414646_at_news.arnes.si>


On Fri, 15 Jan 1999 12:21:41 +0000, Maarten Meijer <M.Meijer_at_accu.uu.nl> wrote:

>Hello Oracle programmers,
>Could anyone solve this little problem? In a PL/SQL program,
>I'm trying to
>
>select ... from ...
>where time0 between time1 and time2
>
>time0, time1 and time2 are of type DATE, but I'm only interested
>in the time portion of these dates!
>Since time0 is being input by a user, the date portion of time0
>is set to the first of the current month and year, while time1
>and time2 can have other month and year values.
>So how do I ignore these day, month and year values??

You'll have to use date-to-char conversion, using SQL function TO_DATE with the appropriate format mask. Your query will look something like:

SELECT .... FROM ....
WHERE TO_CHAR(time0,'HH24MISS') BETWEEN
  TO_CHAR(time1,'HH24MISS') AND TO_CHAR(time2,'HH24MISS');

>Thanks!
>--
>Maarten Meijer (030)2531660/2805001 http://www.accu.nl/~mmeijer
> ACCU (Academisch Computercentrum Utrecht) fax (030)2531633
> Budapestlaan 6, P.O.Box 80011, 3508 TA Utrecht NL

Jurij Modic <jmodic_at_src.si>
Certified Oracle7 DBA (OCP)



The above opinions are mine and do not represent any official standpoints of my employer Received on Fri Jan 15 1999 - 23:26:58 CET

Original text of this message