PostgreSQLDate/Time FunctionsDATE_TRUNC
DATE_PART

DATE_TRUNCDate/Time Functions

TO_DATE

Truncates a date/time to the specified precision.

Syntax

DATE_TRUNC('field', source)

Example

Enter values below to update the example in real time.

order_date
total_amount
revenue
orders
-- 월별 집계
SELECT DATE_TRUNC('month', order_date) AS month,
       SUM(total_amount) AS revenue
FROM orders
GROUP BY month
ORDER BY month;