Database Reference
In-Depth Information
Two examples in the following two queries have their results shown
in Figure 9.8.
SELECT EXTRACT(YEAR FROM DATE '2004-02-09') AS YEAR
, EXTRACT(MONTH FROM DATE '2004-02-09') AS MONTH
, EXTRACT(DAY FROM DATE '2004-02-09') AS DAY
FROM DUAL;
SELECT EXTRACT(YEAR FROM SYSDATE) AS YEAR
, EXTRACT(MONTH FROM SYSDATE) AS MONTH
, EXTRACT(DAY FROM SYSDATE) AS DAY
FROM DUAL;
Looking at some general date function examples, the next query uses
several date functions. The final expression uses the SYSDATE function
and subtracts two dates. The results are in days, so to help compare the
MONTHS_BETWEEN function and the next column, that following col-
Figure 9.8
The EXTRACT
Function Retrieves
Parts of Dates.
Search WWH ::




Custom Search