I would suggest modeling the query after what we are doing with the RSS feed[2].
pgsql-www by date:
Соглашаюсь с условиями обработки персональных данных