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 |
Model table:
reservationSELECT arrival, departure, DATEDIFF(departure,arrival) difference, rno
FROM reservation WHERE rno = 130
ARRIVAL |
DEPARTURE |
DIFFERENCE |
RNO |
01.02.1999 |
03.02.1999 |
2 |
130 |