@edmond_brakus
You can use the date_trunc
function along with the interval
keyword to filter data from two years ago in PostgreSQL.
Here's an example query:
1 2 3 4 |
SELECT * FROM your_table WHERE date_column >= date_trunc('year', current_date - interval '2 years') AND date_column < date_trunc('year', current_date - interval '1 year') |
In this query, date_column
is the column in your table that contains the date you want to filter on. The date_trunc
function is used to get the start of the year for the current date minus 2 years and the start of the year for the current date minus 1 year, effectively filtering data from two years ago.