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

From: markr69 <markr69_at_ally.ios.com>
Date: 1996/03/28
Message-ID: <315B806B.4CAF_at_ally.ios.com>#1/1


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

Just subtract the two date values.
For example:
SELECT SYSDATE - TO_DATE('03-02-1996','MM-DD-YYYY') FROM dual; The result is fractional in days.
This example is Oracle specific. Date handling tends to vary between database vendors. For example, Ingres also allows subtraction, but returns a special data type called an 'Interval'. Regards,
Mark Rosenthal Received on Thu Mar 28 1996 - 00:00:00 CET

Original text of this message