If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Query for Add Months

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-10-11, 06:39
deb_84 deb_84 is offline
Registered User
 
Join Date: Nov 2011
Posts: 7
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.
Reply With Quote
  #2 (permalink)  
Old 11-10-11, 07:58
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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:

Code:
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')
Reply With Quote
  #3 (permalink)  
Old 11-11-11, 01:07
deb_84 deb_84 is offline
Registered User
 
Join Date: Nov 2011
Posts: 7
Thanks a lot!!!! It's working now with your code
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On