Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to calculate difference in time?
The difference between two dates is returned in day's as an integer. Oracle
stores date's only down to seconds. So if you want the difference in seconds
try this:
dbms_output.put_line(to_char((date_Y - date_X) * 24 * 60 * 60));
Robert Chung schrieb in Nachricht <35eb009c.28919313_at_news.mindspring.com>...
>
>Does anyone know how to calculate difference in time? Following is
>something that I tried.
>
>declare
> date_X date;
> date_Y date;
>begin
> date_X:=SYSDATE;
>
> -- Do something. Spend some time
>
> date_Y:=SYSDATE;
> dbms_output.put_line(
> to_char(date_Y-date_X,
> 'MM:DD:YYYY HH24:MI:SS'));
>end;
>/
>
>Following is the output that I got.
>
>Statement processed.
>##########
>
>All I want is the difference in time (possibly to the micro second).
>Is there any way to do it? Thank you.
>
Received on Mon Sep 21 1998 - 03:15:36 CDT