PostgreSQLDate/Time FunctionsDATE_PART
EXTRACT

DATE_PARTDate/Time Functions

DATE_TRUNC

Returns a specific field of a date/time as a number.

Syntax

DATE_PART('field', source)

Example

Enter values below to update the example in real time.

order_id
created_at
order_hour
orders
SELECT order_id, DATE_PART('hour', created_at) AS order_hour
FROM orders;