oracle - How can I get this data in a single row -
select to_char(x,'mon'),to_char(x,'dd') (select case when to_char(to_date('01-may-2015')+(rownum-1),'dy') = 'fri' then<br> to_date('01-may-15')+(rownum-1) else null end x all_objects<br> rownum < (select (to_date ('01-may-16') - to_date('01-may-15')+1) <br> dual)) x not null;
i want display the date of friday on every week of month give year, starting give date.
suppoise if give start date 01-mar-2015 29-feb-2016 ten should like
mar mar mar mar apr apr apr apr may............feb feb
06 13 20 27 3 10------------------------- 19 26
i getting them in columns. how can them in row. in advance.
you may need this:
with test(start_date) (select to_date('15022016', 'ddmmyyyy') dual) /* start date */ select listagg(to_char(date_, 'dd/mm/yyyy'), ', ') within group(order date_) /* concatenation of dates */ ( select start_date + level -1 date_ /* generate dates */ test connect start_date + level -1 <= add_months(start_date, 12) /* keep dates in 1 year starting date */ ) to_char(date_, 'd') = 5 /* check if friday, 5th day of week */
i put comments in code give minimum explanation af different parts.
Comments
Post a Comment