在mssql 2005 中between 。。。and .. 与getdate() 的结合使用注意:

mssql 2005 中between 。。。and .. 与getdate() 的结合使用注意:

select getdate() as now
2010-12-14 14:44:11.277

select * from xmstc.student s where getdate() between '2010-12-10' and '2010-12-14' ;
查询出来结果为空 因为此处between ..and  .. 不包括边界值'2010-12-14', 可能是因为日期后面还包含时分秒的关系吧

通过convert() 把getdate() 转换为'yyyy-MM-dd' 的格式即可,即包含边界值 :
select * from student s  where convert(varchar(11),getdate(),111) between s.createtime and '2010-12-14'

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

«    2025年11月    »
12
3456789
10111213141516
17181920212223
24252627282930
搜索
标签列表
网站分类
最新留言
    文章归档
    友情链接

    Powered By Z-BlogPHP 1.7.4

    Copyright Your WebSite.Some Rights Reserved.闽ICP备11018667号-2