首页 > 数据库技术 > 详细

oracle 根据周次获取周开始结束日期

时间:2014-04-15 01:09:25      阅读:646      评论:0      收藏:0      [点我收藏+]
select 
  the_week,
  sunday,
  saturday,
  to_char(sunday,‘yyyyMMdd‘)||‘-‘||to_char(saturday,‘yyyyMMdd‘) week_desc


 from (select sunday.the_week,
       decode(sign(sunday.the_day - saturday.the_day),
              -1,
              sunday.the_day,
              sunday.the_day - 7) sunday,
       saturday.the_day saturday
  from (         select decode(to_char(wwm,‘yyyy/mm/dd‘),‘2014/01/01‘,‘1‘,to_char(wwm, ‘WW‘)+1) the_week,
                to_char(wwm, ‘D‘) the_daynum,
               wwm the_day
          from (select trunc(to_date(‘2014-01-01‘, ‘yyyy-mm-dd‘), ‘MM‘) + rownum - 1 as wwm
                  from user_objects
                 where rownum < 366)
         where to_char(wwm, ‘D‘) = 1 or to_char(wwm,‘yyyy/mm/dd‘)=‘2014/01/01‘) sunday,
       (                 select to_char(wwm, ‘WW‘)+0 the_week,
               to_char(wwm, ‘D‘) the_daynum,
               wwm the_day
          from (select trunc(to_date(‘2014-01-01‘, ‘yyyy-mm-dd‘), ‘MM‘) + rownum - 1 as wwm
                  from user_objects
                 where rownum < 366)
         where to_char(wwm, ‘D‘) = 7 or to_char(wwm,‘yyyy/mm/dd‘)=‘2014/12/31‘) saturday
 where sunday.the_week = saturday.the_week)


where THE_WEEK=?

oracle 根据周次获取周开始结束日期,布布扣,bubuko.com

oracle 根据周次获取周开始结束日期

原文:http://blog.csdn.net/gefangliang/article/details/23683057

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!