select count(*)
from SupplementDemand
where and datediff(hh,CreateTime,getdate())<1
我想查的是与当前时间相差1小时之内的数据,请问我这样写对吗?
解决方案 »
- 比对结果
- sql serv2000导出为VFP的.DBF文件和从VFP的.dbf文件导入时提示错误,请问怎么处理?
- 求一SQL语句,进入看详情,在线等
- '100.200.011.101,1433' ; 'sa' ; 'sa'如何保存到一个字段中
- SQL SERVER与ACCESS数据同步的问题.
- 数据库高戍进来,看看这棵树该怎么建起来。谢谢!
- sql 按in中的集合来排序
- 请问ASA中与SQL SERVER中的@@FETCH_STATUS作用相同的sql语法是什么?
- 高分求救-如何在win2k下同时安装sql server 7和2000?
- 考勤程序的關鍵問題?
- FULL JOIN 可以联合空表吗
- 请教关于多个数据表中查询名称相同的一列
from SupplementDemand
where and datediff(hh,CreateTime,getdate())<1这个去掉就行!
from SupplementDemand
where datediff(hh,CreateTime,getdate())<1
这样就可以了
select count(*)
from SupplementDemand
where abs(datediff(hh,CreateTime,getdate()))<1
select count(*)
from SupplementDemand
where datediff(mi,CreateTime,getdate()) between 0 and 60
当CreateTime大于getdate()时,返回的是负数
若要求小于当前时间,且与当前时间相差一小时,则用如上sql,
若只要求与当前时间相差一小时,则为between -60 and 60
from SupplementDemand
where datediff(hh,CreateTime,getdate())<1
from SupplementDemand
where abs(datediff(hh,CreateTime,getdate()))<1这个