Return subfields such as year or hour from date or timestamp values
DATE_PART(field string, source date or timestamp) → integer
- field: Must be one of the following: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND.
- source: The value from which to extract the subfield
select date_part('year', timestamp '2021-04-01 15:27:32') -- 2021
select date_part('month', date '2021-04-01') -- 4
Was this page helpful?
Glad to hear it! Thank you for your feedback. Sorry to hear that. Thank you for your feedback.