SQL$HELP_OLD72.HLB  —  Built In Functions, CURRENT_DATE
    The CURRENT_DATE function returns a DATE data type value (ANSI
    format) containing year, month, and day for date 'today'. You
    can specify an optional fractional-seconds precision for CURRENT_
    DATE.

    Example: Using the CURRENT_DATE function

    The following example shows how a site with an Oracle Rdb
    database might use the CURRENT_DATE function to determine
    employee ages. You must use the CAST function to convert the
    DATE column BIRTHDAY from VMS to ANSI format to use it with the
    ANSI format CURRENT_DATE function.

    SQL> ATTACH FILENAME 'corporate_data';
    SQL> SET SCHEMA 'ADMINISTRATION.PERSONNEL';
    SQL> CREATE VIEW AGE (LAST_NAME, FIRST_NAME, BIRTHDAY, AGE)
    cont>       AS SELECT LAST_NAME, FIRST_NAME, BIRTHDAY,
    cont>        (CURRENT_DATE - CAST(BIRTHDAY AS DATE ANSI)) YEAR TO MONTH
    cont>       FROM EMPLOYEES ORDER BY BIRTHDAY ASC LIMIT TO 10 ROWS;
    SQL> --
    SQL> -- A SELECT statement displays the ten oldest employees.
    SQL> SELECT * FROM AGE;
     LAST NAME        FIRST_NAME       BIRTHDAY         AGE
     O'Sullivan       Rick             12-Jan-1923       68-06
     Clairmont        Rick             23-Dec-1924       66-07
     Nash             Walter           19-Jan-1925       66-06
     Kinmonth         Louis             7-Apr-1926       65-03
     Bartlett         Dean              5-Mar-1927       64-06
     Johnson          Bill             13-Apr-1927       64-03
     Herbener         James            28-Oct-1927       63-09
     Babbin           Joseph           12-Dec-1927       63-07
     Ziemke           Al               27-Oct-1928       62-09
     Reitchel         Charles          13-Dec-1928       62-07
    10 rows selected
    SQL>
Close Help