Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何根据用户输入将一个月分成几个星期,比如从一个月的第一天或一周的第一周开始。
示例:如果用户想要基于每月 1 天的数据,即 2012 年 1 月 6 日,那么
2012 年 6 月 1/6-7/6 8/6-14/6 15/6-21/6 22/6-28/6 29/6-30/6
如果用户想要根据第一周,即 2012 年 4 月 6 日
2012 年 6 月 4-10 11-17 18-24 我认为这将是一个财政周
谁能告诉我我怎么能得到这个?
以及如何根据给定日期获得完整的一周
这可以给你一个想法,
declare vdate date := sysdate; temp Date; begin temp := VDate; WHILE last_day(temp) >= vDate LOOP dbms_output.put_line(to_char(vDate)); vDate := vDate+7; END LOOP; end; end;
结果将从今天(2012 年 12 月 10 日)开始到本周的最后一天
10-DEC-12 17-DEC-12 24-DEC-12 .....