Function documentationDATEDIFF(t,s) Locate this document in the navigation structure

 

DATEDIFF(t,s) is a date function that calculates the number of days between a start and end date.

t and s values: When used in a function, the expressions t and s (date_or_timestamp_expression) must supply a date, a time stamp, or an alphanumeric value that matches the current date or time stamp format.

DATEDIFF(t,s)

t, s

Result of DATEDIFF(t,s) Function

Positive difference between t and s

Numeric value (number of days)

t or s are time stamp values

Only the dates in the time stamp value are used to calculate DATEDIFF(t,s).

t or s is a NULL value

NULL value

Example Example

SELECT arrival, departure, DATEDIFF(departure,arrival) difference, rno

  FROM reservation

    WHERE rno = 130

ARRIVAL

DEPARTURE

DIFFERENCE

RNO

2005-02-01

2005-02-03

2

130

End of the example.