In Oracle Database, the SYSTIMESTAMP
function returns the system date, including fractional seconds and time zone, of the system on which the database resides.
The returned value is of type TIMESTAMP WITH TIME ZONE
.
Syntax
The syntax goes like this:
SYSTIMESTAMP
So, no arguments are required (or accepted), and there are no parentheses.
Example
Here’s an example:
SELECT SYSTIMESTAMP
FROM DUAL;
Result:
06/AUG/21 07:45:00.540362000 PM -04:00
This example displays the date based on the value of my system’s NLS_DATE_FORMAT
parameter (which is currently DD/MON/RR
). We can change the NLS_DATE_FORMAT
parameter, or use a function like TO_CHAR()
to return the result in a different format.
Example:
SELECT TO_CHAR(SYSTIMESTAMP, 'YYYY-MM-DD HH24:MI:SS TZR')
FROM DUAL;
Result:
2021-08-06 19:48:43 -04:00
Calling SYSTIMESTAMP
with Parentheses
As mentioned, the SYSTIMESTAMP
function is called without parentheses.
Here’s what happens when we call it with parentheses:
SELECT SYSTIMESTAMP()
FROM DUAL;
Result:
Error starting at line : 1 in command - SELECT SYSTIMESTAMP() FROM DUAL Error at Command Line : 1 Column : 21 Error report - SQL Error: ORA-30088: datetime/interval precision is out of range 30088. 00000 - "datetime/interval precision is out of range" *Cause: The specified datetime/interval precision was not between 0 and 9. *Action: Use a value between 0 and 9 for datetime/interval precision.