Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Comparing Dates

Re: Comparing Dates

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Thu, 27 May 1999 20:42:23 GMT
Message-ID: <374dac07.11674877@inet16.us.oracle.com>


On Thu, 27 May 1999 14:33:01 +0200, "Fred Ruffet" <fruffet_at_kaptech.com> wrote:

>I know this, but what is the unit for the result of date1-Date2 ?

number of days

if date1 - date2 = .5 then they differ by a half a day

if you want it in the number hours then   (date1-date2)*24

number of minutes
  (date1-date2)*24*60

number of seconds
  (date1-date2)*24*60*60

eg.

given...

SQL> desc t

 Name                            Null?    Type
 ------------------------------- -------- ----
 D1                                       DATE
 D2                                       DATE

  1 select
  2 to_char( d1, 'DD-MON-YYYY HH24:MI:SS' ) d1,   3 to_char( d2, 'DD-MON-YYYY HH24:MI:SS' ) d2   4* from t
SQL> /

D1                   D2
-------------------- --------------------
27-MAY-1999 16:33:01 27-MAY-1999 04:33:01 then...

  1 select
  2 d1-d2 days,

  3    (d1-d2)*24 hours,
  4    (d1-d2)*24*60 minutes,
  5    (d1-d2)*24*60*60 seconds

  6* from t
SQL> /       DAYS HOURS MINUTES SECONDS ---------- ---------- ---------- ----------

        .5 12 720 43200

hope this helps

chris.

>
>Fred
>
>

--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu May 27 1999 - 15:42:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US