DATEDIFF(t,s) 

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

t and s: date or timestamp expression

 

Result of DATEDIFF(t,s) function

Positive difference between t and s

Numeric value (number of days)

t or s are timestamp values

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

t or s is NULL value

NULL value (see data type)

Model table: reservation

SELECT arrival, departure, DATEDIFF(departure,arrival) difference, rno
FROM reservation WHERE rno = 130

ARRIVAL

DEPARTURE

DIFFERENCE

RNO

02/01/1999

02/03/1999

2

130