Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL query on Quarterly dates

vijzMay 9 2018 — edited May 9 2018

-- SQL Query to check Each quarter 1st day and Last dat of this Quarter based on sysdate:

SELECT To_char(Trunc(Add_months(Add_months(Trunc(sysdate, 'Y') - 1,

                                                 To\_number(To\_char(sysdate, 

                                                           'Q')) \* 

                                                 3), -2) 

           , 'MM'), 'mm/dd/yyyy hh24:mi:ss')         First\_Day\_Quarter, 

   To\_char(Add\_months(Trunc(sysdate, 'Y') - 1, To\_number(To\_char(sysdate, 

                                                         'Q')) \* 3 

           ) + ( 

           86399 / 86400 ), 'mm/dd/yyyy hh24:mi:ss') Last\_Day\_Quarter 

FROM dual

pastedImage_6.png

What is the SQL query to check previous quarter 1st Day (starting at midnight) and Last day (ending at 23:59:59) based on the Sysdate?

This post has been answered by AndrewSayer on May 9 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 6 2018
Added on May 9 2018
4 comments
752 views