Specifying current date and time values

 

You can specify a current date, time, or timestamp in an expression by using one of these special registers: CURRENT DATE, CURRENT TIME, and CURRENT TIMESTAMP.

The value of each is based on a time-of-day clock reading obtained during the running of the statement. Multiple references to CURRENT DATE, CURRENT TIME, or CURRENT TIMESTAMP within the same SQL statement use the same value. The following statement returns the age (in years) of each employee in the EMPLOYEE table when the statement is run:

   SELECT YEAR(CURRENT DATE - BIRTHDATE)
     FROM CORPDATA.EMPLOYEE

The CURRENT TIMEZONE special register allows a local time to be converted to Universal Time Coordinated (UTC). For example, if you have a table named DATETIME that contains a time column type with a name of STARTT, and you want to convert STARTT to UTC, you can use the following statement:

   SELECT STARTT - CURRENT TIMEZONE
     FROM DATETIME

 

Parent topic:

Date, time, and timestamp data types