It's a varchar not a date column, so use substring
SUBSTRING(datacompleta, 0, 4) AS mes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello, i have the following field in varchar. "mes" how do i extract or get the year only from that year_month ? i tried this in multiple synthaxes and use the year() and none of them worked. " EXTRACT(YEAR_MONTH FROM datacompleta) AS mes "
It's a varchar not a date column, so use substring
SUBSTRING(datacompleta, 0, 4) AS mes
Please or to participate in this conversation.