oracle大于当前月,oracle 现阶段年 当前月 当前周 当前日
當前位置:我的異常網? 數據庫???oracle 現階段年 當前月 當前周 當前日
oracle 現階段年 當前月 當前周 當前日
www.myexceptions.net??網友分享于:2013-08-16??瀏覽:296次
oracle 當前年 當前月 當前周 當前日
Oracle 當前月 當前周 當前年? 2010-12-15 15:54:04|? 分類: 數據庫 -- oracle |? 標簽:t.c? reate_time? sysdate? trunc? where?? |字號大中小 訂閱 .
當月數據
select * from table t
where t.create_time >=TRUNC(SYSDATE, 'MM')
and t.create_time<=last_day(SYSDATE) create_time為你要查詢的時間
當年數據
select * from table t
where t.create_time >=trunc(sysdate,'YYYY')
and t.create_time<=add_months(trunc(sysdate,'YYYY'),12)-1
本周(國外周日為一個星期第一天)
where t.create_time >=trunc(sysdate,'day')+1 and t.create_time<=trunc(sysdate,'day')+6 本周(國內周一為一個星期第一天)
where t.create_time >=trunc(next_day(sysdate-8,1)+1) and t.create_time<=trunc(next_day(sysdate-8,1)+7)
select
trunc(next_day(sysdate - 8, 1) + 1) as 周一,
trunc(next_day(sysdate - 8, 1) + 2) as 周二,
trunc(next_day(sysdate - 8, 1) + 3) as 周三,
trunc(next_day(sysdate - 8, 1) + 4) as 周四,
trunc(next_day(sysdate - 8, 1) + 5) as 周五,
trunc(next_day(sysdate - 8, 1) + 6) as 周六,
trunc(next_day(sysdate - 8, 1) + 7) as 周日
from dual;
-----查詢當期日期之前一個月的日期
select trunc(sysdate) - rownum +1? as tdate
from all_objects
where rownum <=? (trunc(sysdate) - add_months(trunc(sysdate),-1 ))
-----當日9:00--21:00
select * from A where to_char(sysdate,'hh24:mi') between '09:00' and? '21:00'? where to_char(A.time,'yyyy-MM-dd)=to_char(sysdate,'yyyy-MM-dd);
-----oracle SQL語句中查詢一個月內固定時間段的數據,比如9月1號到10月1號每天的八點到九點的呼叫數目
select * from table where createdate
between to_date('2010-9-1','yyyy-MM-dd') and to_date('2010-10-1','yyyy-MM-dd')
and EXTRACT(hour from createdate) between '8:00' and '9:00';
select a.日期,count(*) from 表名 a
where to_char(a.具體時間,'HH') <= '21' and to_char(a.具體時間,'HH')>='20'
group by a.日期
having to_char(a.日期,'YYYY-MM-DD')<='2011-10-01' and to_char(a.日期,'YYYY-MM-DD')>='2011-09-01'
-----當前月的天數
select trunc(sysdate) - rownum +1? as tdate
from all_objects
where rownum <= (trunc(sysdate)+1 - trunc(last_day(add_months(sysdate,-1))+1))
-----當月里的第一天,最后一天,總數
select (trunc(last_day(SYSDATE)) + 1 -
add_months(trunc(last_day(add_months(sysdate, -1)) + 1), 0)) totalday,
sysdate,
add_months(sysdate, 0) aa,
last_day(SYSDATE) lastday,
last_day(add_months(sysdate, -1)) + 1 firstday
from dual;
文章評論
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的oracle大于当前月,oracle 现阶段年 当前月 当前周 当前日的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 安卓应用市场下载(手机安卓市场下载)
- 下一篇: iOS16.4Beta3更新了什么内容值