"CyberMaya <<Alex Bautista>>" <alex(at)cybermaya(dot)com> writes:
> Hola!
>
> uso la ver. 7.0
>
> ¿existe una funcion para obtener el año y mes de una fecha?
> algo asi como
> SELECT ... FROM ... WHERE YEAR(fecha)= aaaa AND MONTH(fecha) = mm
La función date_part hace la magia:
test0=# select date_part('year',now());
date_part
-----------
2002
(1 row)
Revisa:
http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
Saludos,
Manuel.