匠吉财富
您的当前位置:首页mssql日期函数[数据库中查询整数天或者整数月]

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

来源:匠吉财富


//查询当前的

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 '不是'

//检测当前的时间是否比保存的时间正好过了整数天或者整数个月

显示全文