DB agnostic SQL for CURRENT_TIMESTAMP

Viewed 1997

I'm currently using Oracle, but most of the SQL is db agnostic. One exception is CURRENT_TIMESTAMP which fails in MSSQL. Is is possible to move to a more portable syntax for this too?

2 Answers

The jOOQ user manual can be useful for these kinds of lookups, as well as the SQL translation website. From the manual:

-- Access
now()

-- Sybase ASE
current_bigdatetime()

-- MariaDB, MemSQL, MySQL, Snowflake
current_timestamp()

-- BigQuery, CockroachDB, CUBRID, Db2, Derby, EXASOL, Firebird, H2, HANA, HSQLDB,
-- Ignite, Ingres, Oracle, PostgreSQL, Redshift, SQLite, SQL Server, Teradata
-- Vertica
CURRENT_TIMESTAMP

-- Informix
CURRENT

-- Sybase SQL Anywhere
CURRENT TIMESTAMP

Disclaimer: I work for the company behind jOOQ.

Related