Re: Is there a function in SQL to calculate days between two dates?
Date: 1996/03/29
Message-ID: <4jglut$12gi_at_darwin.nbnet.nb.ca>#1/1
jiang_at_ccs.neu.edu (Hong Jiang) wrote:
>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
Oracle's PL/SQL supports a full set of date operators. There are many ways of finding the days between 2 dates. The simplest is
x := trunc(date1) - trunc(date2);
The trunc will set the hours:minutes:seconds to 12:00:00 for the variables date1 and date2. Both these variables should be declared as date.
Gene Maillet Received on Fri Mar 29 1996 - 00:00:00 CET