如何 用 SQL 语句比较查询 指定时段的记录,忽略字段时间部分? SQL SRVER 2005 中 有一个表A 表A 中 有字段 A,B其中 字段 A 为 Datetime 类型请教大家 ,怎么根据 字段A 检索 指定日期段 的记录 (忽略时间部分)比如 返回 2011-1-1 至 2011-3-8 之间的记录(只要日期符合条件就行) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 convert(varchar(8),date,120) between '2011-1-1' and '2011-3-8' select * from A where convert(varchar(10),A,120) between '2011-01-01' and '2011-03-08' select * from tb where A between '2011-1-1' and '2011-3-8' if(getdate() between '2011-1-1' and '2011-3-8') print 'true'else print 'false'/*false select * from tb where A between '2011-1-1' and cast('2011-3-8' as datetime)+1 --用上索引 select *from tbwhere convert(varchar(8),date,120) between '2011-1-1' and '2011-3-8' where a between '2011-1-1' and '2011-3-8' sql2005怎样设置用户的表权限。。 请看我帖出的存储过程和它的出错信息,毛病在哪儿? 一个在SQL中取数据的问题 我要在数据库表中存储图片信息应该怎样定义,存储 一个算法问题,各位大哥请进,很急~ 数据库表中数据丢失 这个函数的速度,还可以优化吗? 问一个级联的问题 在SQL Server中怎么格式化字符串? 关于转换日期格式时碰到的奇葩问题 怎么把SQL中的数据变为可用的变量 问SQL2005修改表字段错误。
select * from tb where A between '2011-1-1' and '2011-3-8'
if(getdate() between '2011-1-1' and '2011-3-8')
print 'true'
else
print 'false'/*
false
*
from
tb
where
convert(varchar(8),date,120) between '2011-1-1' and '2011-3-8'