SYSDATE Operator
The SYSDATE operator returns the current DATETIME value from the system clock. SYSDATE is identical to the CURRENT operator, except that the default precision of SYSDATE is YEAR TO FRACTION(5), while the default precision of CURRENT is YEAR TO FRACTION(3).
On Windows™ platforms that do not support a seconds scale greater than FRACTION(3), SYSDATE is in effect a synonym for the CURRENT operator,
You can use SYSDATE in any context where the CURRENT operator is valid.
The SQL statements in the following example use the SYSDATE
operator to specify the default values for two DATETIME columns of
a database table, and to insert a new row into the table:
CREATE TABLE tab1 ( id SERIAL, value CHAR(20), time1 DATETIME YEAR TO FRACTION(5) DEFAULT SYSDATE, time2 DATETIME YEAR TO SECOND DEFAULT SYSDATE YEAR TO SECOND ); INSERT INTO tab1 VALUES (0, ‘description', SYSDATE, SYSDATE);
The following query accesses the table that was created
in the previous example:
SELECT SYSDATE AS sysdate, * FROM tab1;
The results are sensitive to the date and time when the
INSERT and SELECT statements are issued, but the query could return
these values on September 23, 2007:
sysdate 2007-09-23 21:30:23.00000 id 1 value description time1 2007-09-23 21:29:27.00000 time2 2007-09-23 21:29:27
The next query accesses the same table, using SYSDATE in
the WHERE clause as an argument to the DAY function:
SELECT *, DAY(time1) AS day FROM tab1 WHERE DAY(time1) = DAY(SYSDATE);
The query could return these values on September 23, 2007:
id 1 value description time1 2007-09-23 21:29:27.00000 time2 2007-09-23 21:29:27 day 23
Only HCL OneDB™ supports SYSDATE. Except for its name and its default precision, the description of the CURRENT operator in this document also describes the SYSDATE operator.