Showing posts with label Oracle Database. Show all posts
Showing posts with label Oracle Database. Show all posts

Monday, September 17, 2012

Oracle Database Start of the quater and End of the quater

You can use the below to get the start and end of the quarter for any given date. The below example uses sysdate.


Select Add_Months(Trunc(Sysdate,'mm'), -Mod(To_Number(To_Char(Sysdate,'mm'))+2,3)) quarter_start,
add_months(trunc(sysdate,'mm'), mod(to_number(to_char(sysdate,'mm'))+2,3))-1/86400 quarter_end
from dual;

Results:


QUARTER_START             QUARTER_END              
------------------------- -------------------------
01-JUL-2012 00:00:00      31-OCT-2012 23:59:59  




Related Posts Plugin for WordPress, Blogger...