oracle 查询两个日期间的数据???

濤子 2010-02-20 09:39:48
想查询一个表中的日期列edate,查询要的结果是edate between '某月某日' and '某月某日'之间的数据;因为刚学习Oracle,写了一个老是说月份无效
select * from tbl_empl from edate between to_date(0112,'mmdd') and to_date(1201,'mmdd');
这个语句为什么老报月份无效异常呢??
...全文
1150 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
老黎 2010-02-21
  • 打赏
  • 举报
回复

select * from your_table a where to_char(a.time_column,'yyyy-mm-dd') between '2010-01-01' and '2010-02-21'
Raul_Gonzalez 2010-02-21
  • 打赏
  • 举报
回复
引用 7 楼 liusong_china 的回复:
是笔误吗? 丢了where。


恩..
  • 打赏
  • 举报
回复
select  *  from  table  where  rq  between(to_date(' 2010-2-10' ,' yyyy-mm-dd' ))  and  (to_date(' 2010-2-19' ,' yyyy-mm-dd' ))  
select  *  from  table  where  rq> =to_date(' 2010-2-10' ,' yyyy-mm-dd' )  and  larq  < =to_date(' 2010-2-19' ,' yyyy-mm-dd' )
liusong_china 2010-02-21
  • 打赏
  • 举报
回复
是笔误吗? 丢了where。
liusong_china 2010-02-21
  • 打赏
  • 举报
回复
引用楼主 ning109314 的回复:
想查询一个表中的日期列edate,查询要的结果是edate between '某月某日' and '某月某日'之间的数据;因为刚学习Oracle,写了一个老是说月份无效
select * from tbl_empl from edate between to_date(0112,'mmdd') and to_date(1201,'mmdd');
这个语句为什么老报月份无效异常呢??


select * from tbl_empl where edate between to_date(0112,'mmdd') and to_date(1201,'mmdd');
iqlife 2010-02-21
  • 打赏
  • 举报
回复
oracle 日期范围查询问题


select * from aaa where to_char(rq,'yyyymmdd') between '20011101' and '20020301';


直接在rq上加函数,如果应用大(这个表内数据很多时),查询速度会相当慢的,为了提高查询速度,强烈建议这样书写:
select * from aaa where rq between to_date('2001-11-01','yyyy-MM-DD') and to_date('2002-03-01' ,'YYYY-MM-DD');


推荐使用
select * from aaa where rq>;=to_date('2001-11-01','yyyy-MM-DD') and rq<=to_date('2002-03-01' ,'YYYY-MM-DD');

用between的函数可能会慢些
濤子 2010-02-20
  • 打赏
  • 举报
回复
引用 2 楼 tiancx82 的回复:
select * from tbl_empl from to_char(edate,'mmdd')  between '0112' and  '1201';

tiancx82
您写的这个还是有错 可能是我刚才没说清楚,edate类型是date类型的
濤子 2010-02-20
  • 打赏
  • 举报
回复
引用 1 楼 you_tube 的回复:
edate数据类型是?

数据类型是Date类型的,对不起刚才没说清楚
tiancx82 2010-02-20
  • 打赏
  • 举报
回复
select * from tbl_empl from to_char(edate,'mmdd') between '0112' and '1201';
you_tube 2010-02-20
  • 打赏
  • 举报
回复
edate数据类型是?

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧