Home > Database > Mysql Tutorial > mssql日期函数[数据库中查询整数天或者整数月]

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:47:29
Original
1280 people have browsed it

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

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

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template