我有一张下表projects
。
id title created_at claim_window
1 Project One 2012-05-08 13:50:09.924 5
2 Project Two 2012-06-01 13:50:09.924 10
A)我想通过计算找到截止日期deadline = created_at + claim_window(No. of days)
。
类似于以下的东西。
id title created_at claim_window deadline
1 Project One 2012-05-08 13:50:09.924 5 2012-05-13 13:50:09.924
2 Project Two 2012-06-01 13:50:09.924 10 2012-06-11 13:50:09.924
B) 我也想找到截止日期已经过去的项目
id title created_at claim_window deadline
1 Project One 2012-05-08 13:50:09.924 5 2012-05-13 13:50:09.924
我尝试如下。
SELECT * FROM "projects"
WHERE (DATE_PART('day', now()- created_at) >= (claim_window+1))
但由于某种原因,它不起作用。