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

    Question Unanswered: oracle date function

    by default oracle has defined quarter as starting from jan-mar, apr-jun, july-sep, oct-dec.
    if i want to define my own quater such as feb-apr as 1st quarter and so on , how can i achieve it?
    thanks

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    You could write your own stored function to do it.

  3. #3
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    You can also push it down, using add_months,
    i.e.
    Code:
    SQL@8i> select month,
      2         to_number( to_char( month, 'Q')) quarter,
      3         to_number( to_char( add_months( month, - 1), 'Q' )) pushed_quarter
      4    from (
      5  select add_months( to_date( '01-jan-2004', 'dd-mon-yyyy'), rownum - 1 ) month
      6    from all_objects
      7   where rownum <= 12
      8         )
      9  /
    
    MONTH        QUARTER PUSHED_QUARTER
    --------- ---------- --------------
    01-JAN-04          1              4
    01-FEB-04          1              1
    01-MAR-04          1              1
    01-APR-04          2              1
    01-MAY-04          2              2
    01-JUN-04          2              2
    01-JUL-04          3              2
    01-AUG-04          3              3
    01-SEP-04          3              3
    01-OCT-04          4              3
    01-NOV-04          4              4
    01-DEC-04          4              4
    
    12 rows selected.
    
    SQL@8i>

Posting Permissions

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