关于日期到期查询的问题

mrbai 2008-04-07 03:11:01
我从biaozhun库中间查取b_yxq字段,字段类型datetime
我想查询本月到期的内容我用了如下两种方法,都有点问题,大家帮忙看看问题在什么地方
select * from [biaozhun] where datediff("d",b_yxq,getdate())<30

select * from [biaozhun]WHERE (b_yxq < GETDATE() - 30)
...全文
80 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
JL99000 2008-04-07
select * from [biaozhun] where datediff("d",b_yxq,getdate()) <30
--
select * from [biaozhun] where datediff( d,b_yxq,getdate()) <30

select * from [biaozhun]WHERE (b_yxq < GETDATE() - 30)
--
select * from [biaozhun] WHERE b_yxq < (GETDATE()-30)
回复
byg1983109 2008-04-07
select * from [biaozhun] where datediff(day,b_yxq,getdate())<30
回复
hui_hui_2007 2008-04-07
关注。
回复
ojuju10 2008-04-07

查询本月到期

select * from biaozhun where datediff(mm,b_yxq,getdate)=0
回复
ojuju10 2008-04-07

select * from [biaozhun] where datediff(d,b_yxq,getdate()) <30
回复
RoverX 2008-04-07
select * from [biaozhun] where b_yxq>= convert(varchar(7),getdate(),120)+'-01' and b_yxq<convert(varchar(7),dateadd(mm,1,getdate()),120)+'-01'
回复
areswang 2008-04-07
select * from [biaozhun] where datediff(d,b_yxq,getdate()) <30
回复
-狙击手- 2008-04-07
我想查询本月到期



select *
from [biaozhun]
WHERE datediff(m,b_yxq,GETDATE()) = 0
回复
wzy_love_sly 2008-04-07
select * from [biaozhun] 
where datediff(dd,b_yxq,getdate()) <30
回复
青锋-SS 2008-04-07
select * from [biaozhun] where datediff(d,b_yxq,getdate()) <30 

select * from [biaozhun] WHERE b_yxq < dateadd(d,- 30,GETDATE() )
回复
青锋-SS 2008-04-07
select * from [biaozhun] where datediff(d,b_yxq,getdate()) <30 

select * from [biaozhun] WHERE (b_yxq < dateadd(d,- 30,GETDATE() )
回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2008-04-07 03:11
社区公告
暂无公告