Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Comparing Dates
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
.5 12 720 43200
hope this helps
chris.
>
>Fred
>
>
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.
![]() |
![]() |