DATEDIFF(t,s) is a date function that calculates the number of days between a start and end date.
Values t and s: When used in a function, the expressions t and s (date_or_timestamp_expression) must both supply a date, a time stamp, or an alphanumeric value that matches the current date or time stamp format.
|
Result of the 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 a NULL value |
NULL value |
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 |