PostgreSQL, a verificar a data relativa a"hoje"

Estava a pensar se alguém poderia ajudar com alguns Postgres. Eu tenho uma tabela que tem uma coluna chamada mydate que é um tipo de data postgres. Quero fazer algo como:
SELECT * FROM MyTable WHERE mydate > [Today-1year]
[[3] eu nunca usei Postgres antes e tenho certeza que só preciso saber o nome de algumas funções-eu mesmo vou olhar para a referência. Alguém me pode indicar a direcção certa?

Obrigado!

Author: OMG Ponies, 2010-10-14

4 answers

select * from mytable where mydate > now() - interval '1 year';
 104
Author: Paul Tomblin, 2010-10-13 22:37:28
Acho que isto serve.
SELECT * FROM MyTable WHERE mydate > now()::date - 365;
 49
Author: Alex Howansky, 2010-10-13 22:36:14

Isto deve dar-te a data actual menos 1 ano:

select now() - interval '1 year';
 7
Author: coderaj, 2010-10-13 22:38:00

Também pode verificar com a função age()

select * from mytable where age( mydate, now() ) > '1 year';

age() devolveremos um intervalo.

Por exemplo age( '2015-09-22', now() ) vai voltar -1 years -7 days -10:56:18.274131

Ver documentação pós-gresql

 2
Author: Doc, 2016-09-29 08:57:29