w3resource

PostgreSQL DATE_TRUNC() function

DATE_TRUNC() function

The date_trunc() function is used to truncate to specified precision.

Syntax:

date_trunc(text, timestamp)

Return Type: timestamp.

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL DATE_TRUNC() function

Pictorial presentation of postgresql DATE_TRUNC function

Example: PostgreSQL DATE_TRUNC() function :

Example:

Code:

SELECT date_trunc('hour', timestamp '2002-09-17 19:27:45');

Sample Output:

     date_trunc
---------------------
 2002-09-17 19:00:00
(1 row)

Previous: DATE_PART function
Next: EXTRACT function



Follow us on Facebook and Twitter for latest update.