w3resource

STATEMENT_TIMESTAMP() function

STATEMENT_TIMESTAMP() function

The PostgreSQL STATEMENT_TIMESTAMP() function is used to get the current date and time at the start of the current statement.

Uses of STATEMENT_TIMESTAMP() Function
  • Retrieve the exact timestamp at the beginning of the current statement execution.

  • Useful for precise logging and auditing of statement execution times.

  • Helps in performance monitoring by capturing the time when a specific statement was executed.

Syntax:

statement_timestamp()

Return Type: timestamp with time zone

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL STATEMENT_TIMESTAMP() function

Pictorial presentation of PostgreSQL STATEMENT_TIMESTAMP() function

Example: PostgreSQL STATEMENT_TIMESTAMP() function

Code:

SELECT statement_timestamp();

Sample Output:

    statement_timestamp
----------------------------
 2015-01-15 14:30:28.322-08
(1 row)

N.B. - The outputs may change during the execution for the current date.

Previous: NOW function
Next: TIMEOFDAY function



Follow us on Facebook and Twitter for latest update.