如何在postgresqldate时间添加天数

我有一个下面的表格projects

 id title created_at claim_window 1 Project One 2012-05-08 13:50:09.924437 5 2 Project Two 2012-06-01 13:50:09.924437 10 

A)我想find计算deadline = created_at + claim_window(No. of days)

像下面的东西。

 id title created_at claim_window deadline 1 Project One 2012-05-08 13:50:09.924437 5 2012-05-13 13:50:09.924437 2 Project Two 2012-06-01 13:50:09.924437 10 2012-06-11 13:50:09.924437 

B]我也想find截止date不到的项目

 id title created_at claim_window deadline 1 Project One 2012-05-08 13:50:09.924437 5 2012-05-13 13:50:09.924437 

我尝试像下面这样的东西。

 SELECT * FROM "projects" WHERE (DATE_PART('day', now()- created_at) >= (claim_window+1)) 

但由于某种原因,这是行不通的。

这会给你最后期限:

 select id, title, created_at + interval '1' day * claim_window as deadline from projects 

要在截止date之前完成所有项目,请使用:

 select * from ( select id, created_at + interval '1' day * claim_window as deadline from projects ) t where localtimestamp at time zone 'UTC' > deadline