oracle SQL语句取本周本月本年的数据
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');
--本年的
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。