您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mssql日期函数[数据库中查询整数天或者整数月]

2025/9/8 11:13:44发布26次查看
mssql日期函数[中查询整数天或者整数月]
select //查询整月的
  *
from
  tb
where
  datediff(hh,时间字段,getdate())=0
select dateadd(mm,2,getdate())
select dateadd(day,2,getdate())
//查询日与小时
datediff(dd,time,getdate())   --日
datediff(hh,time,getdate())   --小时
//查询当前的
select * from #tb where dateadd(mm,2,datacol)=getdate()//查询现在的所有数据
select
  *
from
  tb
where
  datediff(hh,时间字段,getdate())=0 --时
  and datediff(mi,时间字段,getdate())=0--秒//用
declare @num int
set @num=2
if  dateadd(d,@num,'2010-01-05 1:00')=getdate() or dateadd (m,2,'2010-01-05 1:00')=getdate()
print '是'
else
print '不是'//检测当前的时间是否比保存的时间正好过了整数天或者整数个月
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product