SQL Server中的时间匹配 [英] Time matching in sql server
本文介绍了SQL Server中的时间匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取最近五分钟添加的所有记录.
我有一个名为
的表
I want to fetch all records which are added in last five minutes.
I am having table named as
customer
{
name varchar(50),
wdate datetime
}
请帮忙.
please help.
推荐答案
您可以使用DATEDIFF:
You can use DATEDIFF :
select * from customer where DATEDIFF(mi,wdate, getdate()) < 5
在System.DateTime.Now.AddMinutes(-5)和System.DateTime之间的wdate之间使用. Now()将其添加到查询中
use between wdate between System.DateTime.Now.AddMinutes(-5) and System.DateTime.Now() lyk this in query
这篇关于SQL Server中的时间匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文