oracle按时间查询

1.按月查询时,下面这条语句可以获取下个月1号

select  add_months( to_date('2006-12-1','yyyy-MM-dd'), 1)  from dual  ;

2.下面语句可以查询2006年12月数据

select * from wf_wfinfo t where t.wfstarttime between to_date('2006-12-1','yyyy-MM-dd')

and (select  add_months( to_date('2006-12-1','yyyy-MM-dd'), 1)  from dual);

也可以简写成:

select * from wf_wfinfo t where t.wfstarttime between to_date('2006-12-1','yyyy-MM-dd')

and ( add_months( to_date('2006-12-1','yyyy-MM-dd'), 1) );

3.一般查询12月数据
SELECT T.*,T.ROWID FROMTABLE t WHERE t.starttime BETWEEN  to_date('2011-12-01','yyyy-MM-dd') AND to_date('2011-12-31','yyyy-MM-dd' ) 
4.下面数据库中时间为字符串查询的一种方式
 select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual
5.数据库中为字符串情况,前台转换数据也为字符串情况:
select to_date(t.operatime,'yyyy-mm-dd hh24:mi:ss') from inck_t_adsl_devnbr_ne_log t
where to_date(t.operatime,'yyyy-mm-dd hh24:mi:ss')>=to_date('2010-03-10 00:00:00','yyyy-mm-dd hh24:mi:ss') and
 to_date(t.operatime,'yyyy-mm-dd hh24:mi:ss')<=to_date('2011-03-10 00:00:00','yyyy-mm-dd hh24:mi:ss');
 
select to_date(t.operatime,'yyyy-mm-dd hh24:mi:ss') from inck_t_adsl_devnbr_ne_log t
where to_date(t.operatime,'yyyy-mm-dd hh24:mi:ss') between to_date('2010-03-10 00:00:00','yyyy-mm-dd hh24:mi:ss') and
 to_date('2011-03-10 00:00:00','yyyy-mm-dd hh24:mi:ss');

select to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss')    from dual
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值