Entering content frame

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

Example table: reservation

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

ARRIVAL

DEPARTURE

DIFFERENCE

RNO

01/02/2002

03/02/2002

2

130

 

 

Leaving content frame