description |
---|
Return subfields such as year or hour from date or timestamp values. |
- field: Must be one of the following: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND.
- source: The value from which to extract the subfield.
Examples
{% code title="DATE_PART example" %}
SELECT DATE_PART('year', TIMESTAMP '2021-04-01 15:27:32')
-- 2021
{% endcode %}
{% code title="DATE_PART example" %}
SELECT DATE_PART('month', DATE '2021-04-01')
-- 4
{% endcode %}