SQL SYSTIMESTAMP function
Returns the current TIMESTAMP WITH TIME ZONE, read from the database server's operating-system clock, with fractional seconds (six digits on most platforms).
- Catégorie
- Dates & times
- Returns
TIMESTAMP WITH TIME ZONE- In this category
- 15 of 121
Syntaxe
SYSTIMESTAMP
SYSTIMESTAMP AT TIME ZONE 'UTC'
Each block is a separate form. The support table and the examples show which engine takes which.
Prise en charge des moteurs
| Moteur | Support | Notes |
|---|---|---|
| SQL Server | Different name or syntax | SYSDATETIMEOFFSET() |
| PostgreSQL | Different name or syntax | NOW() returns timestamptz |
| MySQL | Different name or syntax | NOW(6) has fractions but no zone |
| SQLite | Different name or syntax | strftime('%Y-%m-%d %H:%M:%f', 'now') is UTC text, no zone |
| Oracle | Oui | Supported under this name. |
Exemples
Oracle
SELECT SYSTIMESTAMP AS loaded_at FROM dual;
Oracle
SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) AS utc_ts FROM dual;
Bon à savoir
- SYSTIMESTAMP uses the DB server clock; CURRENT_TIMESTAMP uses the session time zone. They can differ by hours in one query.
- The value is time-zone aware, but assigning it into a plain TIMESTAMP column drops the zone and keeps the wall time.
- MySQL and SQLite have no zone-aware current timestamp; store UTC and convert in the application there.
Questions about SYSTIMESTAMP
How do I get UTC from SYSTIMESTAMP?
SYS_EXTRACT_UTC(SYSTIMESTAMP) or SYSTIMESTAMP AT TIME ZONE 'UTC' both return the instant in UTC.
Is SYSTIMESTAMP the same as SYSDATE?
SYSDATE returns plain DATE with second precision and no zone; SYSTIMESTAMP returns TIMESTAMP WITH TIME ZONE with fractional seconds.
Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.
Related on SQLly
Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite, Oracle.
Functions your engine actually has
SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.