oracle SQL语句取本周本月本年的数据

2014-11-24 12:44:32 · 作者: · 浏览: 0
oracle SQL语句取本周本月本年的数据
[sql] 
--国内从周一到周日 国外是周日到周六  
select to_char(sysdate-1,'D') from dual;--取国内的星期几 去掉减一取国外的星期--  

[sql] 
--取本周时间内的数据  
select * from table  where DTIME >=trunc(next_day(sysdate-8,1)+1) and DTIME<=trunc(next_day(sysdate-8,1)+7)+1 ;  
  
select * from table  where DTIME >
=trunc(next_day(sysdate-8,1)) and DTIME<=trunc(next_day(sysdate-8,1)+7);--国外的 select * from table where DTIME >=TRUNC(SYSDATE, 'MM') and DTIME<=last_day(SYSDATE); --本月的 select * from table where to_char(DTIEM,'yyyy')=to_char(sysdate,'yyyy'); --本年的