select tdate, to_char(tdate,'day')
from (
select to_date('2011-03-18','yyyy-mm-dd') + rownum -1 as tdate
from all_objects
where rownum <= to_date('2011-03-30','yyyy-mm-dd') - to_date('2011-03-18','yyyy-mm-dd') + 1
) t
where to_char(tdate,'day') = '星期一'
其中t表是构建你需要的这一个时间段的日期列表, to_char(days,'day')得到的结果是星期几
select
from (select to_date('2013-01-01', 'yyyy-mm-dd') + rownum - 1 days
from dba_objects) a
where extract(year from days) = 2013
and to_char(days, 'WW') = 22
and to_char(days, 'day') in ('星期一', '星期二', '星期三', '星期四', '星期五')
年份:2013,第几周:22
SELECT to_char(SYSDATE,'iw') -to_char(last_day(add_months( SYSDATE,-1))+1,'iw')+1 FROM DUAL;
这样统计出来的每月的1号所在的周为第一周
select SUNDAY,SATURDAY from
(select
sundaythe_week,decode(sign(sundaythe_day-saturdaythe_day),-1,sundaythe_day,sundaythe_day-7)
sunday,saturdaythe_day saturday from
(select to_char(wwm,'WW') the_week,to_char(wwm,'D') the_daynum,wwm the_day from (select
trunc(sysdate, 'MM')+rownum-1 as wwm from user_objects where rownum < 366) where
to_char(wwm,'D')=1 ) sunday,
(select to_char(wwm,'WW') the_week,to_char(wwm,'D') the_daynum,wwm the_day from (select
trunc(sysdate, 'MM')+rownum-1 as wwm from user_objects where rownum < 366) where
to_char(wwm,'D')=7 ) saturday
where sundaythe_week=saturdaythe_week) a
where the_week=32
以上就是关于Oracle查询一段日期内的星期的日期..例如我要查2011-3-18至2011-3-30内所有星期一的日期..应该怎样查询全部的内容,包括:Oracle查询一段日期内的星期的日期..例如我要查2011-3-18至2011-3-30内所有星期一的日期..应该怎样查询、oracle 获取指定周的星期一到星期五日期、oracle 确定日期为本月第几周等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)