DATE_TRUNC('month', d)::date AS month_start, -- First day of the month DATE_TRUNC('year', d)::date AS year_start, -- First day of the year EXTRACT(YEAR FROM d)::int ...