extract year_month + filter by year

PHOTO EMBED

Wed Feb 12 2025 17:56:01 GMT+0000 (Coordinated Universal Time)

Saved by @kastokes

SELECT * 
FROM (
    SELECT date_part(year, date::date) AS y,
           date_part(month, date::date) AS m

    FROM table_name
    
) subquery

WHERE y >= 2024;
content_copyCOPY

extracts the year and month part from a column named date, which is explicitly cast to a DATE type and then filters records where the extracted year (y) >= 2024