oracle数据库怎么判断某个时间在一段时间之内

oracle数据库中有两个时间字段。比如:
开始时间:2013-03-01
结束时间:2013-06-01
输入一个时间,如何判断在时间范围内。比如:输入2013-04-01就在时间范围内

用to_char函数即可。

如emp表中数据如下:

要查询hiredate的日期为1981年1月1日到1981年5月1日之间的数据,可用如下语句:

select * from emp where to_char(hiredate,'yyyy-mm-dd') between '1981-01-01' and '1981-05-01';

查询结果:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-09-02

用Between

select * from 表名 where 列名 between '2013-03-01' and '2013-06-01'

第2个回答  2013-09-02
declare @check_date datetime
select @check_date='2013-04-01'
select @check_date as 时间, case when exists(select 1 from table_name
    where @check_date between table_name.开始时间 and table_name.结束时间)
    then '在' else '不在' end as 是否在区间内

第3个回答  2013-09-02
select * from mytable t where t.startTime>=to_date('2013-04-01','yyyy-mm-dd') and t.endTime<=to_date('2013-04-01','yyyy-mm-dd')本回答被提问者采纳