这种是很简单的了 1、把你传入的参数,应该是一个日期吧,根据这个日期获得它一周的数据,比如说可今天是9.22,你就获取9.22-9.28的日期 2、然后将第一步获取的日期范围传入到你的查询条件中,select * from table where insert_time between 9.22 and 9.28 像这样不就可了吗?
select * from table where insert_time between to_char(insert_time,'yyyyMMdd')='20130922' and to_char(insert_time,'yyyyMMdd')='20130928'
这种是很简单的了 1、把你传入的参数,应该是一个日期吧,根据这个日期获得它一周的数据,比如说可今天是9.22,你就获取9.22-9.28的日期 2、然后将第一步获取的日期范围传入到你的查询条件中,select * from table where insert_time between 9.22 and 9.28 像这样不就可了吗?oracle中有个函数to_char(字段,'w')
月份和周数 都可以已参数的方式传进来进行查询 with t1 as ( select date'2013-08-02' c1 from dual union all select date'2013-08-05' c1 from dual union all select date'2013-08-08' c1 from dual union all select date'2013-08-11' c1 from dual union all select date'2013-08-22' c1 from dual union all select date'2013-08-26' c1 from dual )select * from t1 where to_char(c1,'w')=2 and c1 >= to_date('2013-08','yyyy-mm') and c1 < add_months(to_date('2013-08','yyyy-mm'),1) c1 ----------------------- 1 2013/8/8 2 2013/8/11
select * from table t where to_char(t.insert_time, 'mm') = 8 and to_char(t.insert_time, 'w') = 2;
这种是很简单的了
1、把你传入的参数,应该是一个日期吧,根据这个日期获得它一周的数据,比如说可今天是9.22,你就获取9.22-9.28的日期
2、然后将第一步获取的日期范围传入到你的查询条件中,select * from table where insert_time between 9.22 and 9.28 像这样不就可了吗?
这种是很简单的了
1、把你传入的参数,应该是一个日期吧,根据这个日期获得它一周的数据,比如说可今天是9.22,你就获取9.22-9.28的日期
2、然后将第一步获取的日期范围传入到你的查询条件中,select * from table where insert_time between 9.22 and 9.28 像这样不就可了吗?oracle中有个函数to_char(字段,'w')
with t1 as
(
select date'2013-08-02' c1 from dual union all
select date'2013-08-05' c1 from dual union all
select date'2013-08-08' c1 from dual union all
select date'2013-08-11' c1 from dual union all
select date'2013-08-22' c1 from dual union all
select date'2013-08-26' c1 from dual
)select *
from t1
where to_char(c1,'w')=2
and c1 >= to_date('2013-08','yyyy-mm')
and c1 < add_months(to_date('2013-08','yyyy-mm'),1) c1
-----------------------
1 2013/8/8
2 2013/8/11
from table t
where to_char(t.insert_time, 'mm') = 8
and to_char(t.insert_time, 'w') = 2;