DAYS_BETWEEN

Purpose

This function returns the number of days between two date values.

Syntax

days_between::=

Usage Notes

  • If a timestamp is entered, only the date contained therein is applied for the computation.
  • If the first date value is earlier than the second date value, the result is negative.
  • For data type TIMESTAMP WITH LOCAL TIME ZONE this function is calculated within the session time zone.

Example

SELECT DAYS_BETWEEN(DATE '1999-12-31',DATE '2000-01-01') DB1,
       DAYS_BETWEEN(TIMESTAMP '2000-01-01 12:00:00',
                    TIMESTAMP '1999-12-31 00:00:00') DB2;
Result
DB1 DB2
-1 1