sql里怎么直接使用某一时间,比如datediff要查09年8月到9月的数据 select time from Table1 where time datediff(month,20090908,20090909)=1请给个能正确运行的代码这样出错啊消息 4145,级别 15,状态 1,第 1 行在应使用条件的上下文(在 'datediff' 附近)中指定了非布尔类型的表达式。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select [time] from Table1 where convert(varchar(7),[time],120) between '2009-08' and '2009-09' select [time] from Table1 where datediff(month,[time],'20090909') between 0 and 1 我再问的简单点。。有个time列,里面有条数据时 '2009-9-29 18:47:04' 我怎么就查不到呢,兄弟们帮我看看我的sql语句:select time from article where time='2009-9-29 18:47:04' 月份是两位的,用09,还有datetime型一般含有毫秒数据,所以不建议这样直接去匹配 select time from article where convert(varchar(19),[time],120)='2009-09-29 18:47:04' 哦,谢谢你。原来查询时间,SQL与语句里一定要改成varchar类型啊有没有convert转换成时间类型的呢? 如果是时间格式的数据,用cast()就可以了select cast('2009-09-29 18:47:04' as datetime)/** ------------------------------------------------------ 2009-09-29 18:47:04.000(所影响的行数为 1 行)**/ 有关sysobject提问: mssql 问题,如何 select * 是全部? 求sql语句——在线 循环帮忙解释一下. 超难--挑战者来看一下 急急急!!!SQL函数问题 没有分了 在线等 Update的简单问题 MSSQL的存储过程里面怎么实现类似功能? 请各位帮帮忙,我连接不到数据库 sql 语句拆分成关键字、字段、表达式 就是有段.sql的脚本文件。想直接调用这个文件 创建数据库。怎么实现 关于一对多的查询,求更好的方法
from Table1
where convert(varchar(7),[time],120) between '2009-08' and '2009-09'
from Table1
where datediff(month,[time],'20090909') between 0 and 1
有没有convert转换成时间类型的呢?
如果是时间格式的数据,用cast()就可以了select cast('2009-09-29 18:47:04' as datetime)/**
------------------------------------------------------
2009-09-29 18:47:04.000(所影响的行数为 1 行)
**/