Protected by Copyscape Web Copyright Protection Software

Pages

Search This Blog

Monday, April 28, 2014

Periods query

Hi All,

Write a query to display two periods based on one period.
If I give 'MAR-12' It should display 'APR-12' and 'SEP-12'
If I give 'SEP-12' It should display 'OCT-12' and 'MAR-13'
If I give 'APR-13' It should display 'MAY-13' and 'OCT-13'


Like this which ever period I give I need Next period to 6 months.

If I give 'DEC-11' It should display 'JAN-12' and 'JUN-12'

Answer:
-----------


SELECT to_char(add_months(dd,1),'MON-RR') start_preiod ,
     to_char(add_months(dd ,6),'MON-RR') end_preiod   
FROM (SELECT to_date (:P_PERIOD,'MON-RR') dd FROM dual
     );

 Keep watching for updates.......

No comments:

Post a Comment