程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> oracle根據周次獲取周開始結束日期

oracle根據周次獲取周開始結束日期

編輯:Oracle教程

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=?

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved