New versions: Dev (3.16) | Latest (3.15) | 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, MARIADB, MEMSQL, MYSQL
CAST(current_timestamp() AS timestamp with time zone)

-- AURORA_POSTGRES, BIGQUERY, CUBRID, DB2, DERBY, EXASOL, FIREBIRD, H2, HANA, HSQLDB, IGNITE, 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)

-- SNOWFLAKE
CAST(current_timestamp() AS timestamp_tz)

-- SQLDATAWAREHOUSE, SQLSERVER
CAST(CURRENT_TIMESTAMP AS datetimeoffset)

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

(These are currently generated with jOOQ 3.16, see #10141), or translate your own on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo