昨天的数据:
select * from table
where to_date(to_char(sysdate,'yyyy-mm-dd')) - to_date(to_char(createtime,''yyyy-mm-dd'')) = 1;
前天的数据:
select * from table
where to_date(to_char(sysdate,'yyyy-mm-dd')) - to_date(to_char(createtime,''yyyy-mm-dd'')) = 2;
本周的数据:
select * from table
where createtime >=trunc(sysdate,'day')+1 and createtime<=trunc(sysdate,'day')+6;
上周的数据:
select * from table
where createtime >=trunc(sysdate,'day')-6 and createtime<=trunc(sysdate,'day')-1;
一个月前的数据:
select * from table
where createtime < trunc(sysdate,'month')-1
一年前的数据:
select * from table
where createtime < trunc(sysdate,'year')-1
本月的数据:select * from table where createtime >=TRUNC(SYSDATE, 'MM') and createtime<=last_day(SYSDATE);
任意时间之间的数据:
select * from table where createtime>=to_date('starttime','YYYY-MM-DD HH24:MI:SS')
and createtime<=to_date('endtime','YYYY-MM-DD HH24:MI:SS')
orcle中时间段数据的查询
最新推荐文章于 2024-03-15 11:36:30 发布