To facilitate the calculation of dates and times, a series of functions are available that can use values of these data types to perform calculations.
SELECT arrival,
ADDDATE (arrival,2) new_arrival, rno
FROM reservation
WHERE rno = 130
Postponing the reservation date by two days
Result
ARRIVAL |
NEW_ARRIVAL |
RNO |
2005-02-01 |
2005-02-03 |
130 |
SELECT arrival,
departure, DATEDIFF(departure, arrival) overnight_stays, rno
FROM reservation
WHERE rno = 130
Number of overnight stays
Result
ARRIVAL |
DEPARTURE |
OVERNIGHT_STAYS |
RNO |
2005-02-01 |
2005-02-03 |
2 |
130 |
See also:
Extraction Function (extraction_function)
A variety of date formats (EUR, INTERNAL, ISO, JIS, and USA) are available for processing date values.
See also:
Date and Time Format (datetimeformat)