设为首页 加入收藏

TOP

oracle根据周次获取周开始结束日期
2014-11-24 02:33:03 来源: 作者: 【 】 浏览:3
Tags: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=
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle数据库从WindowXP迁移到Win.. 下一篇学习笔记_oracle――过程函数触发..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++中智能指针的性能 (2025-12-25 03:49:29)
·如何用智能指针实现c (2025-12-25 03:49:27)
·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)