oracle 查询某个月的每天是星期几

select to_date(dy,'yyyy-mm')+(rownum-1) s_date,
       case to_number(to_char(to_date(dy||'-'||rownum,'yyyy-mm-dd'),'d'))
       when 1 then 7
       else to_number(to_char(to_date(dy||'-'||rownum,'yyyy-mm-dd'),'d'))-1
       end  day_week
from
(
       select '2012-6' dy from dual
)
connect by rownum<=last_day(to_date(dy,'yyyy-mm')) - to_date(dy,'yyyy-mm')+1
--红色部分为输入的月份

猜你喜欢

转载自gip666.iteye.com/blog/1631384