[英]Check certain number of days using date in sql
i am new in SQL and need help by a task which we got from school.我是 SQL 的新手,需要我们从学校得到的一项任务的帮助。 The following task is:
下面的任务是:
Who has exceeded the permissible borrowing period of 2 weeks谁超过了2周的允许借款期限
I have already written that code.我已经编写了该代码。
select borrow.user_id from borrow where count(return_date - borrow_date) > 14;
I am not really sure what I am doing there.我不确定我在那里做什么。 I know that its wrong but yea... I don't really know how to do it.
我知道这是错误的,但是是的……我真的不知道该怎么做。
I hope someone understands my problem and can help... Thanks for your advice我希望有人能理解我的问题并能提供帮助...谢谢您的建议
I think you need datediff
as follows:我认为您需要
datediff
如下:
select borrow.user_id,
datediff(return_date, borrow_date) - interval 14 day as over_days
from borrow where datediff(return_date, borrow_date) > 14;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.