New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9

CURRENT_OFFSETDATETIME

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Get the current server time as a SQL TIMESTAMP WITH TIME ZONE type (represented by java.time.OffsetDateTime).

This does the same as CURRENT_TIMESTAMP except that a cast is added, and the client type representation uses JSR-310 types.

SELECT current_timestamp;
create.select(currentOffsetDateTime()).fetch();

The result being something like

+-----------------------+
| current_timestamp     |
+-----------------------+
|   2020-02-03 15:30:45 |
+-----------------------+

Dialect support

This example using jOOQ:

currentOffsetDateTime()

Translates to the following dialect specific expressions:

-- ACCESS
cstr(now())

-- ASE
CAST(current_bigdatetime() AS timestamp with time zone)

-- AURORA_MYSQL, CUBRID, MARIADB, MEMSQL, MYSQL
CAST(current_timestamp() AS timestamp with time zone)

-- AURORA_POSTGRES, DB2, DERBY, FIREBIRD, H2, HANA, HSQLDB, INGRES, ORACLE, POSTGRES, REDSHIFT, SQLITE, TERADATA, VERTICA
CAST(CURRENT_TIMESTAMP AS timestamp with time zone)

-- COCKROACHDB
CAST(CURRENT_TIMESTAMP AS timestamptz)

-- INFORMIX
CAST(CURRENT AS timestamp with time zone)

-- SQLDATAWAREHOUSE, SQLSERVER
CAST(CURRENT_TIMESTAMP AS datetimeoffset)

-- SYBASE
CAST(CURRENT TIMESTAMP AS timestamp with time zone)

(These are currently generated with jOOQ 3.15, see #10141)

The jOOQ Logo