postgressql中的dateadd
我有这张学生桌子桌,想知道那些已经早点完成的桌子。
student-id, loan_amount, date_given, terms, last_paymnt
xxxx xxxx 04/03/2010 36 08/09/2012
xxxx xxxx 16/09/2011 45 13/12/2017
我的逻辑是抓取enter
(当前整数) date_given
作为几个月以cte
中的预定日期,然后在该日期和giend-date
之间获取另一个减法,以使结果在几个月,所以我可以老板和莱特斯。
我正在尝试以下操作,但没有成功:
select date_given + interval 'terms month'
from Student_loan
我将如何将整数添加到日期,并在我的桌子上有几个月甚至减去两个日期并返回一个月?
I have this student_loan table and would like to know those that have finished early.
student-id, loan_amount, date_given, terms, last_paymnt
xxxx xxxx 04/03/2010 36 08/09/2012
xxxx xxxx 16/09/2011 45 13/12/2017
My logic is to grab to add the terms
(currently integer) to thedate_given
as months to have a presumed finished date in a cte
then grab another subtraction between that date and the given-date
to have the result in months so I can the earlies and the lates.
I am trying the below but without success:
select date_given + interval 'terms month'
from Student_loan
How would I add that integer to the date and have a number of months or even subtract the two dates in my table and return a number of month?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
make_interval()
或将一个月间隔乘以列的值:
只需减去它们,结果就是几天的数量,因为这两个列都是(或至少似乎是)
date
值:You can use
make_interval()
Alternatively multiply a one month interval with the value of the column:
Just subtract them, the result of that is the number of days as both columns are (or at least seem to be)
date
values: