Joseph Joseph - 1 year ago 84
SQL Question

PostgreSQL, checking date relative to "today"

Was wondering if someone could assist with some Postgres. I have a table which has a column called

which is a postgres date type. I want to do something like:

SELECT * FROM MyTable WHERE mydate > [Today-1year]

I've never used Postgres before and I'm sure I just need to know the name of some functions- I'll gladly look up the reference myself. Can anyone point me in the right direction?


Answer Source

I think this will do it:

SELECT * FROM MyTable WHERE mydate > now()::date - 365;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download