我想要PostgreSQL中的一个系列,它给出了该日期之前每周间隔的日期
实施例
1) Date Selected is 05/31/2013 So the series must be : 05/31/2013 05/24/2013 05/17/2013 05/03/2013 04/26/2013 2) Date Selected is 05/20/2013 So the series must be : 05/20/2013 05/13/2013 05/06/2013 04/29/2013 04/22/2013
我做了什么:
SELECT *
FROM generate_series('2013-05-03 00:00'::timestamp,'2013-05-31 12:00', '1 weeks')
答案 0 :(得分:4)
这是你追求的吗?
SELECT *
FROM generate_series('2013-05-31 12:00'::timestamp,
'2013-05-03', '-1 weeks');