Looking to pull in data from your PostgreSQL database according to a dynamic date range? We've got you covered!  

Here are some example snippets that you can add to your queries*:

*Replace any instance of  "DATE_COLUMN"  with the name of the date column / field you want to base the filter off of.

Last 30 Days

WHERE "DATE_COLUMN" >= current_date - interval '30' day


WHERE date_trunc('month', date("DATE_COLUMN")) = date_trunc('month', CURRENT_DATE)


WHERE date_trunc('year', date("DATE_COLUMN")) = date_trunc('year', CURRENT_DATE)

Last Month

WHERE date_trunc('month', "DATE_COLUMN") >= date_trunc('month', current_date - interval '1' month)
AND date_trunc('month', "DATE_COLUMN") < date_trunc('month', current_date)

Last Year

WHERE date_trunc('year', "DATE_COLUMN") >= date_trunc('year', current_date - interval '1' year)
AND date_trunc('year', "DATE_COLUMN") < date_trunc('year', current_date)

If you have questions, feel free to email us or chat in on the site!

Did this answer your question?