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?
The CURRENT_TIMESTAMP function returns the current date and time, in a 'YYYY-MM-DD hh:mm:ss. mmm' format. Tip: Also look at the GETDATE() function.
CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are synonyms for NOW() . Returns the current time as a value in 'hh:mm:ss' or hhmmss format, depending on whether the function is used in string or numeric context. The value is expressed in the session time zone.
CURRENT_TIMESTAMP is an ANSI SQL function whereas GETDATE is the T-SQL version of that same function. One interesting thing to note however, is that CURRENT_TIMESTAMP is converted to GETDATE() when creating the object within SSMS. Both functions retrieve their value from the operating system in the same way.
CURRENT_TIMESTAMP returns the current date and time in the session time zone, in a value of datatype TIMESTAMP WITH TIME ZONE . The time zone offset reflects the current local time of the SQL session. If you omit precision, then the default is 6.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With