LOCALTIMESTAMP
LOCALTIMESTAMP in SQL is a function that retrieves the current date and time in the time zone of the current SQL session as set by the database system on your local machine. The retrieved value consists of a TIMESTAMP value without timezone.
LOCALTIMESTAMP[(precision)]
- precision: This parameter defines the number of fractional digits retained in the seconds field. A value of 0 signifies second precision, while a maximum value of 6 signifies microsecond precision. The absence of a precision value defaults the digit precision to 6 in PostgreSQL. The precision value is optional for LOCALTIMESTAMP.
Example
Output
Explanation
The LOCALTIMESTAMP function in PostgreSQL is used to return the current date and time with the fractional part in seconds precision. The output will vary depending on the time of execution. In the given example, LOCALTIMESTAMP is used to return the current timestamp.
LOCALTIMESTAMP [(precision)]
- precision: This optional parameter specifies the number of digits in the fractional part of the SECOND datetime field. It can range between 0 to 9. For example, LOCALTIMESTAMP(5) will give the local date and time down to a hundred thousandths of a second.
Example
Output
Explanation
The LOCALTIMESTAMP
in Oracle returns the current date and time in the local timezone of the database. In the example, it is used in a SELECT
statement to return the value from the dual
table, a dummy table in Oracle.