最佳答案
我有一个下面的表 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) I also want to find the projects whose deadline is gone
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))
But for some reason it is not working.