现在的位置: 首页 > 综合 > 正文

oracle时间查询

2013年12月12日 ⁄ 综合 ⁄ 共 647字 ⁄ 字号 评论关闭

select f.* from tab_regulation   f
where  '1987/8/8'<f.release_date < '2012/5/9'
 and  '1987/8/8'<f.apply_date < '2012/5/9'
 --错误的
 
 select  f.* from tab_regulation   f 
where (
(f.release_date between to_date('1987-8-8','YYYY-MM-DD') and to_date('2012-5-9','YYYY-MM-DD'))
 and 
(f.apply_date between to_date('1987-8-8','YYYY-MM-DD') and to_date('2012-5-9','YYYY-MM-DD')))
--输出3
 
 select  f.* from tab_regulation   f 
where (
(f.release_date between  to_date('1987-8-8 12:00:00','yyyy/mm/dd HH24:mi:ss') and  to_date('2012-5-9 23:59:59','yyyy/mm/dd HH24:mi:ss'))
 and 
(f.apply_date between to_date('1987-8-8 12:00:00','yyyy/mm/dd HH24:mi:ss') and  to_date('2012-5-9 23:59:59','yyyy/mm/dd HH24:mi:ss')))
--输出9

抱歉!评论已关闭.