我有一张桌子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)我想通过计算找到截止日期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]我也想找到截止日期已经过去的项目
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))
但是由于某种原因,它无法正常工作。
timestamp without time zone
current_timestamp的数据类型timestamp with time zone
,因此我没有得到正确的答案