Splitting up an interval in weeks in Postgres

旧时模样 提交于 2019-12-05 21:03:41

You can use the Postgres function generate_series. In 8.3 and earlier, do things like

select current_date + s.a as dates from generate_series(0,14,7) as s(a);

In 8.4, you can also do

SELECT * FROM generate_series('2008-03-01 00:00'::timestamp,
                              '2008-03-04 12:00', '10 hours');

First of all - it would be good to show some sample input and output of the query you'd like us to help you with - I, for example, don't really get what it is that you need.

Also - you might find OVERLAPS to be suboptimal, as it's not indexable. Instead you might want to use the method I described in this blog post.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!