你的这个字段有非法的,就是不能转换在日期的数据.用: select * from 表 where isdate(这个字段)=0 这些记录就是非法的日期.修正这些错误就可以改表结构了,还有日期时间就是固定八位的,不能改.
也可以不用改数据库结构 select ... between convert(datetime,'2002-01-30',120) and convert(datetime,'2002-12-30',120)
我用 select * from jxmx where col011=0 运行,结果是: (0 row(s) affected) 这是说没有非法的数据吗?"2002-01-30" 这个是期长度有10位啊,要变成日期格式,是变成"20020130" 这样的吗?TO wei9625() 那个 120是什么意思啊?
列的内容是2002-01-01的格式,没有双引号。 我重启后已经把VARCHAR格式改成DATATIME了(长度是仍8,改不了),但是用BETWEEN语句还是不行:列名叫col011,表名是jxmxselect * from jxmx where col011 between #2000-1-3# and #2002-1-1# Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near '#'.
用: select * from jxmx where col011 between #2002-01-03# and #2002-12-30#也是上面那个错误提示。Line 1: Incorrect syntax near '#'.
1、用下面检查不是不合法的数据 select * from 你的表 where isdate(你的时间列)=02、修改为合法的时间数据3、修改为datetime类型4、select * from 你的表 where 你的列 between '2000-1-1' and '2002-1-1'
我把#去掉后,没有语法提示了,但是SELECT不出正确的数据。。 晕啊要怎么改啊? select * from jxmx where col011 between 2000-01-03 and 2002-12-30 (0 row(s) affected)
TO pengdali(大力 V2.0) 哇,用你的第4条就正确了。可是书上写的很清楚,说用BETWEEN在日期类数据中查询的时候,两头要用#括起来啊,怎么现在用'可以,用#反而不行了呢??
你的这个字段有非法的,就是不能转换在日期的数据.用:
select * from 表 where isdate(这个字段)=0
这些记录就是非法的日期.修正这些错误就可以改表结构了,还有日期时间就是固定八位的,不能改.
select ... between convert(datetime,'2002-01-30',120) and convert(datetime,'2002-12-30',120)
这是说没有非法的数据吗?"2002-01-30" 这个是期长度有10位啊,要变成日期格式,是变成"20020130" 这样的吗?TO wei9625() 那个 120是什么意思啊?
我重启后已经把VARCHAR格式改成DATATIME了(长度是仍8,改不了),但是用BETWEEN语句还是不行:列名叫col011,表名是jxmxselect * from jxmx where col011 between #2000-1-3# and #2002-1-1#
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '#'.
select * from jxmx where col011 between #2002-01-03# and #2002-12-30#也是上面那个错误提示。Line 1: Incorrect syntax near '#'.
select * from 你的表 where isdate(你的时间列)=02、修改为合法的时间数据3、修改为datetime类型4、select * from 你的表 where 你的列 between '2000-1-1' and '2002-1-1'
select * from jxmx where col011 between 2000-01-03 and 2002-12-30
(0 row(s) affected)
哇,用你的第4条就正确了。可是书上写的很清楚,说用BETWEEN在日期类数据中查询的时候,两头要用#括起来啊,怎么现在用'可以,用#反而不行了呢??