The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.sql  [73 examples] > Database Meta Data  [8 examples]

e288. Listing the Time and Date Functions Supported by a Database

This example gets a list of time and date functions that a database supports.
    try {
        DatabaseMetaData dbmd = connection.getMetaData();
    
        // Get the list of time and date functions
        String timedateFunctions[] = dbmd.getTimeDateFunctions().split(",\\s*");
    } catch (SQLException e) {
    }
Examples in an Oracle database include:
    ADD_MONTHS, LAST_DAY, MONTHS_BETWEEN, NEW_TIME, NEXT_DAY, ROUND,
    SYSDATE, TRUNC
Examples in a MySQL database include:
    DAYOFWEEK,WEEKDAY,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,MONTHNAME,QUARTER,
    WEEK,YEAR,HOUR,MINUTE,SECOND,PERIOD_ADD,PERIOD_DIFF,TO_DAYS,FROM_DAYS,
    DATE_FORMAT,TIME_FORMAT,CURDATE,CURRENT_DATE,CURTIME,CURRENT_TIME,NOW,
    SYSDATE,CURRENT_TIMESTAMP,UNIX_TIMESTAMP,FROM_UNIXTIME,SEC_TO_TIME,
    TIME_TO_SEC

 Related Examples
e284. Listing All Non-SQL92 Keywords Used by a Database
e285. Listing the String Functions Supported by a Database
e286. Listing the Numeric Functions Supported by a Database
e287. Listing the System Functions Supported by a Database
e289. Getting the Maximum Table Name Length in a Database
e290. Listing Available SQL Types Used by a Database
e291. Getting the Name of a JDBC Type

See also: Batching    Connections    Deleting Data    Drivers    Importing and Exporting    Inserting and Updating Data    Oracle OBJECTs    Oracle VARRAYs    Procedures and Functions    Retrieving Data    Scrollable Result Sets    Tables    Updatable Result Sets   


© 2002 Addison-Wesley.