我从数据库查询数据
select * from a where ...
and operate_date >= to_date('2008-12-08', 'yyyy-mm-dd')
and operate_date <= to_date('2008-12-15', 'yyyy-mm-dd')
operate_date是Date类型的,但是现在有一个问题,就是operate_date查出的出具都带有时间,例如2008-12-15 10:26:41
这样的话,我想查15日的就查不出来了,因为15日相当于2008-12-15 00:00:00,是最小的
我试着想把SQL语句改成
and to_date(operate_date,'yyyy-mm-dd') >= to_date('2008-12-08', 'yyyy-mm-dd')
and to_date(operate_date,'yyyy-mm-dd') <= to_date('2008-12-15', 'yyyy-mm-dd')
但是报错,ora-01861 文字与格式字符串不匹配
该怎么办啊??
select * from a where ...
and operate_date >= to_date('2008-12-08', 'yyyy-mm-dd')
and operate_date <= to_date('2008-12-15', 'yyyy-mm-dd')
operate_date是Date类型的,但是现在有一个问题,就是operate_date查出的出具都带有时间,例如2008-12-15 10:26:41
这样的话,我想查15日的就查不出来了,因为15日相当于2008-12-15 00:00:00,是最小的
我试着想把SQL语句改成
and to_date(operate_date,'yyyy-mm-dd') >= to_date('2008-12-08', 'yyyy-mm-dd')
and to_date(operate_date,'yyyy-mm-dd') <= to_date('2008-12-15', 'yyyy-mm-dd')
但是报错,ora-01861 文字与格式字符串不匹配
该怎么办啊??
解决方案 »
- Oracle中怎么实现SQLserver中的break,continue,fetch next功能
- 限制密码长度的触发器……
- Oracle9iAS Forms Services and Oracle Forms Developer 6i Release 2
- 我创建的物化视图,为什么只能刷新一部分数据
- oracle select命令 新手问题求教
- .net连接oracle的配置
- *********update 语句速度问题,帮忙看看**************
- 急: 如何将sql server2000中的image 字段转换成oracle中的相关字段??
- 输出问题
- oracle数据库JOB执行抓数据问题
- oracle数据库联合主键的问题
- awrrpt问题
and to_char(operate_date, 'yyyy-mm-dd') >= '2008-12-08'
and to_char(operate_date, 'yyyy-mm-dd') <= '2008-12-15'
不过我不明白,to_char(operate_date, 'yyyy-mm-dd') 之后就转为字符串了,字符串也能比较大小吗?
and to_char(operate_date,'yyyy-mm-dd')>= '2008-12-08'
and to_char(operate_date,'yyyy-mm-dd')<= '2008-12-15'
and operate_date >= to_date('2008-12-08', 'yyyy-mm-dd')
and operate_date < to_date('2008-12-15', 'yyyy-mm-dd')+1