首页 > 代码库 > oracle日期时间范围查询
oracle日期时间范围查询
Oracle的日期时间范围查询
字段为:字符串类型(char),长度为:10
SELECT * FROM testdatetime t WHERE 1=1 AND t.createdate >= ‘2011-06-01‘ AND t.createdate <= ‘2011-07-05‘;
SELECT * FROM testdatetime t WHERE 1=1 AND to_date(t.createdate,‘yyyy-MM-dd‘)
between to_date(‘2011-06-01‘,‘yyyy-MM-dd‘) and to_date(‘20110705‘,‘yyyymmdd‘) ;
字段为:字符串类型(char),长度为:20
SELECT * FROM testdatetime t WHERE 1=1 AND t.usedate >= ‘2011-06-01‘ AND t.usedate <= ‘2011-07-05‘; SELECT * FROM testdatetime t WHERE 1=1 AND to_date(t.usedate,‘yyyy-MM-dd HH24:MI:SS‘) between to_date(‘2011-07-01 12:00:00‘,‘yyyy-MM-dd HH24:MI:SS‘) and to_date(‘20110702 12:00:00‘,‘yyyymmdd HH24:MI:SS‘) ;
字段为:日期时间类型(date)
SELECT * FROM testdatetime t WHERE 1=1 AND t.startdate >= to_date(‘2011-07-01‘,‘yyyy-MM-dd‘) AND t.startdate <= to_date(‘2011-07-02‘,‘yyyy-MM-dd‘); SELECT * FROM testdatetime t WHERE 1=1 AND t.startdate between to_date(‘2011-07-01‘,‘yyyy-MM-dd‘) AND to_date(‘2011-07-02‘,‘yyyy-MM-dd‘);
SELECT * FROM testdatetime t WHERE 1=1 AND t.startdate = to_date(‘2011-07-01 12:00:00‘,‘yyyy-MM-dd HH24:MI:SS‘);
SELECT * FROM testdatetime t WHERE 1=1 AND to_char(t.startdate,‘yyyy-MM-dd‘) = ‘2011-07-01‘;
SELECT * FROM testdatetime t WHERE 1=1 AND to_char(t.startdate,‘yyyy-MM-dd‘) >= ‘2011-07-01‘ AND to_char(t.startdate,‘yyyy-MM-dd‘) <= ‘2011-07-02‘;
oracle日期时间范围查询
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。