Return year, month, day, and other pieces from a date or timestamp.
Section: Date and Time Functions
Extract date parts
sql
sql
SELECT
EXTRACT(YEAR FROM created_at) AS year_num,
EXTRACT(MONTH FROM created_at) AS month_num
FROM orders;Explanation
Useful for grouping and reporting by calendar parts.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Date and Time Functions