Re: Is there a function in SQL to calculate days between two dates?

From: Scott Urman <surman_at_oracle.com>
Date: 1996/03/29
Message-ID: <4jfbgb$qa3_at_inet-nntp-gw-1.us.oracle.com>#1/1


In article <4jebm8$hfe_at_camelot.ccs.neu.edu>, jiang_at_ccs.neu.edu (Hong Jiang) writes:
|> Hi,
|>
|> I am new in SQL area. Could someone over there tell me there is a function in
|> SQL to calculate days between two dates? For example, how many days between
|> Jan. 23 1995 and Feb. 1 1996? I haven't found any function calculating days
|> directly. I know I could write a pices of program to implement this, but
|> I hope if there is such function I can just call.
|>
|> Thank you very much.
|>
|> Jiang Hong
If you subtract two dates, it gives you the difference in days. For example: DECLARE
  d1 DATE := TO_DATE('07-JAN-96 12:00:00', 'DD-MON-YY HH24:MI:SS');   d2 DATE := TO_DATE('01-JAN-96 00:00:00', 'DD-MON-YY HH24:MI:SS');   x NUMBER;
BEGIN
  x := d1 -d2; -- Assigns 7.5 to x
END;

-- 
Scott Urman
"The opinions expressed here are my own, and are not necessarily that of
 Oracle Corporation"
Received on Fri Mar 29 1996 - 00:00:00 CET

Original text of this message