The jOOQ User Manual : SQL building : Column expressions : Datetime functions : CURRENT_OFFSETDATETIME | previous : next |
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, CUBRID, 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) -- 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.15, see #10141)
Feedback
Do you have any feedback about this page? We'd love to hear it!