Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2011

    Unanswered: Query for Add Months

    I want to find out the count for number of transactions that exists for a quarter{ i.e for three months JAN,FEB,MARCH}. I am using TO_CHAR(ADD_MONTHS(SYSDATE, -2), 'ddMONyyyy') for get the difference.

    For Example SYSDATE is 31st March and then the run the above query. It will give me result as 31st Jan. But i want it from 1st Jan. How will i get the transactions for the remaining days.

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 8
    You should have posted this to the Oracle forum, as this is not ANSI SQL.

    You can use Oracle's built-in "Quarter" Calculation for this:

    SELECT *
    FROM your_table
    WHERE extract(year from sysdate) = extract(year from your_date_column)
    AND to_char(sysdate, 'Q') = to_char(your_date_column, 'Q')

  3. #3
    Join Date
    Nov 2011
    Thanks a lot!!!! It's working now with your code

Posting Permissions

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