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

来源:互联网 发布:淘宝优惠券网站制作 编辑:程序博客网 时间:2024/04/28 01:56
--国内从周一到周日 国外是周日到周六select to_char(sysdate-1,'D') from dual;--取国内的星期几 去掉减一取国外的星期--
--取本周时间内的数据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');--本年的

原创粉丝点击