根據給定的周數,計算本周的起始和結束日期
SELECT NEXT_DAY(TO_DATE('20100101', 'yyyymmdd'),'星期一') + 1 * 7 - 7 AS first_day,
NEXT_DAY(TO_DATE('20100101', 'yyyymmdd'),'星期一') + 1 * 7 - 1 AS LAST_DAY
FROM DUAL;
計算一年中53個周分別的起始與結束日期
SELECT tab_1.COLUMN_VALUE,
NEXT_DAY(TO_DATE('
0101', 'mmdd'),'星期一') + tab_1.COLUMN_VALUE * 7 - 7 AS first_day,
NEXT_DAY(TO_DATE('
0101', 'mmdd'),'星期一') + tab_1.COLUMN_VALUE * 7 - 1 AS LAST_DAY
FROM TABLE
(SELECT SPLIT
('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53',
',')
FROM DUAL
) tab_1
其中SPLIT为自定义函数,用于切分字符串
posted on 2010-01-22 09:38
Ke 阅读(1793)
评论(0) 编辑 收藏 所属分类:
oracle