Entering content frame

This graphic is explained in the accompanying text Date and Time Calculations Locate the document in the library structure

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.

Prerequisites

You require the demo data for the SQL Tutorial.

Start the query tool SQL Studio as database administrator MONA with password RED and log on to the demo database instance DEMODB.

Examples

SELECT arrival, ADDDATE (arrival,2) new_arrival, rno
  FROM hotel.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 hotel.reservation
    WHERE rno = 130

Number of overnight stays

Result

ARRIVAL

DEPARTURE

OVERNIGHT_STAYS

RNO

2005-02-01

2005-02-03

2

130

 

See also:

SQL Reference Manual, Structure linkDate Function (date_function), Structure linkTime Function (time_function), Structure linkExtraction (extraction_function)

 

A variety of date formats (EUR, INTERNAL, ISO, JIS, and USA) are available for processing date values.

See also:

SQL Reference Manual, Structure linkDate and Time Format (datetimeformat)

More examples for Data Query

 

Leaving content frame