I have to split the first three months into weeks. All the weeks should end on saturday and start on friday.
Any suggestions as to how I can accomplish this? Following is my code;
dts as (
select date '2017-01-01' + rownum-1 dt
from dual
connect by level <= 366
),
rpt_fri_sat as
(
select dt,
case when to_char(dt, 'fmday') = 'friday' then dt end fridays,
case when to_char(dt, 'fmday') = 'friday' then rownum end fri_id,
case when to_char(dt, 'fmday') = 'saturday' then dt end saturdays,
case when to_char(dt, 'fmday') = 'saturday' then rownum end sat_id
from dts
where extract(month from dt) < 4
)
select *
from rpt_fri_sat
I want the output to display as follows;
1/1/18 to 1/5/18
1/6/18 to 1/12/18
1/13/18 to 1/19/18
1/20/18 to 1/26/18
1/27/18 to 2/2/18
2/3/18 to 2/9/18
2/10/18 to 2/16/18
2/17/18 to 2/23/18
2/24/18 to 3/2/18
3/3/18 to 3/9/18
3/10/18 to 3/16/18
3/17/18 to 3/23/18
3/24/18 to 3/30/18
Please let me know as to how I can accomplish this task. Any help would be greatly appreciated!