Good morning community,
Currently I need to extract a data from the database, I must group it by the month and the year associated with a certain record, the issue is that the date field was recorded in this way, for example: 2018-08-23 and I only need the month and year, i.e. as a result 2018-08. I was trying with the following script:
SELECT datos, fecha,
LEFT(fecha, 4) AS fechaarreglada
FROM tabla
But it throws me the following error:
ERROR: no existe la función left(date, integer)
LINE 2: LEFT(fechaenvio, 4) AS fechaarreglada
^
HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos.
SQL state: 42883
Character: 35
Any help to help me get the data: 2018-08 is welcome
Use in your case the following;
Convert the date to text and extract the number of characters you need to see.
It would be like this;