星期一到星期日为止如何获得最后90天。
S.no Start_dt End_dt week
1 18-Jul-16 24-Jul-16 Week1
2 25-Jul-16 31-Jul-16 Week2
3 1-Aug-16 7-Aug-16 Week3
4 8-Aug-16 14-Aug-16 Week4
5 15-Aug-16 21-Aug-16 Week5
6 22-Aug-16 28-Aug-16 Week6
7 29-Aug-16 4-Sep-16 Week7
8 5-Sep-16 11-Sep-16 Week8
9 12-Sep-16 18-Sep-16 Week9
10 19-Sep-16 25-Sep-16 Week10
11 26-Sep-16 2-Oct-16 Week11
12 3-Oct-16 9-Oct-16 Week12
13 10-Oct-16 16-Oct-16 Week13
我们需要使用sysdate作为输入。 我正在尝试下面查询它返回当前周一周日,周日日期
SELECT TRUNC(sysdate,'D')+ 1 startofweek,TRUNC(sysdate,'D')+ 7 endofweek FROM dual;
答案 0 :(得分:0)
select trunc(sysdate-(13-rownum)*7, 'iw') start_dt, trunc(sysdate-(12-rownum)*7, 'iw')-1 end_dt, 'week'||rownum week
from dual
connect by rownum<=90/7+1