Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    47

    Question Unanswered: getting startdate of a quarter?

    if i give a date i want all the start date & enddates of the quarters till sysdate..
    example:
    the date given here is 01-jan-2003, so,
    o/p:

    1-jan-2003 to 31-mar-2003
    1-apr-2003 to 31-jun-2003
    and so on till
    1-oct-2004 to 05-nov-2004..

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Code:
    SQL> select add_months(trunc(sysdate,'YYYY'),(rownum-1)*3) start_date
      2  ,      least(trunc(sysdate),add_months(trunc(sysdate,'YYYY'),rownum*3)-1) end_date
      3  from   all_objects
      4  where  rownum <= to_number(to_char(sysdate,'Q'));
    
    START_DATE  END_DATE
    ----------- -----------
    01-JAN-2004 31-MAR-2004
    01-APR-2004 30-JUN-2004
    01-JUL-2004 30-SEP-2004
    01-OCT-2004 05-NOV-2004
    Now no doubt someone else will post a much slicker way!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •