查询sqlserver特定时间段中的某个id的语句怎么写?(仅有的一点分数全部送上求!) 比如,有id为01,02,03的三大类资料,每大类资料中都有不同时间上传的文件,如2007-08-12,2007-08-13等等现在如果要查询资料大类id为02,时间为2007-08-12到2007-08-16之间的所有文件,这语句该怎么写?而且我的时间是string格式的,查询前要不要转化为datatime格式的?该怎么转换?谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from tb where id='02' and cast([date] as datetime) between '2007-8-12' and dataadd(ms,-1,dataadd(dd,1,'2007-8-16'))--或者select * from tb where id='02' and datediff(dd,'2007-8-12',[date])>=0 and datediff(dd,'2007-8-16',[date])<=0 Microsoft SQL Server 2000 Reporting Services 安装事宜 怎么查询总数? 急求:该查询功能如何实现的.查询最大的部门 大量插入数据用触发器还是作业 好? 创建视图问题的问题 在查询分析器中如何看到数据库的规则和默认啊?? 清理表(继上贴)。。。 一个查询问题 sql查询问题 Report Services 安装 请问高手这个查询怎么解决? sql附加问题
and cast([date] as datetime) between '2007-8-12' and dataadd(ms,-1,dataadd(dd,1,'2007-8-16'))
--或者select * from tb where id='02'
and datediff(dd,'2007-8-12',[date])>=0 and datediff(dd,'2007-8-16',[date])<=0