LOCALTIMESTAMP
LOCALTIMESTAMP[(precision)]
Section titled “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
Section titled “Example”SELECT LOCALTIMESTAMP;Output
Section titled “Output” localtimestamp-------------------------------- 2022-04-20 12:43:16.987654+00(1 row)Explanation
Section titled “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)]
Section titled “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
Section titled “Example”SELECT LOCALTIMESTAMP FROM dual;Output
Section titled “Output”27-SEP-21 03.41.32.798000000 PMExplanation
Section titled “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.