2012/8/21 Edson - Listas <[email protected]>
>
> Olá Pessoal,
>
> Como extrair o mês e ano em um campo data no PostgreSql?
> Exemplo: (08/2012)
>
> Extrair só a data eu consegui...
>
> select EXTRACT(MONTH from a.dt_mov) mes,sum(a.vlr_final)total
> from movdirhe a
> where a.dt_mov between '01/01/2010' and '21/08/2012'
>
> group by EXTRACT(MONTH from a.dt_mov)
>
> order by mes asc
>
> Edson
>


Use a função date_trunc('month', a.dtmov).

http://www.postgresql.org/docs/current/interactive/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC

Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a