1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Query to get period start date and period end date.

Discussion in 'SQL PL/SQL' started by jagadekara, Sep 10, 2014.

  1. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Hi All,

    I have two parameters in my query.

    and my_date between :p1 and :p2

    I am passing OCT-11 and MAR-12 to that parameters.

    But we need to convert those into 01-OCT-11 and 31-MAR-12.

    So How can I achieve this?
     
  2. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    Hi,

    Try the following:

    Code (SQL):
    SELECT to_date('OCT-11', 'MON-YY'), add_months(to_date('MAR-12','MON-YY'),1)-1 FROM dual;
     
     
    jagadekara likes this.
  3. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Thanks Rajen.

    Very Simple answer. Working fine.

    Actually I too tried and succeed but very complex than you.
     
  4. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hi.

    alternative....
    Code (SQL):


    SELECT to_date('OCT-11', 'MON-YY'), last_day(to_date('MAR-12','MON-YY')) FROM dual;

    SQL>
     
    BEGIN_DATE  END_DATE
    ----------- -----------
    01.10.2011  31.03.2012
     
     
     
    jagadekara likes this.
  5. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Thanks Sergey.

    Your code is also simple and working fine. That's why daily I roam around this club. This is useful to know different ways , ideas and thoughts.

    Thanks All.