You can translate the question and the replies:

SQL Start & End Dates of Previous Quarter

Hello - what is the syntax for start and end dates of the previous quarter? For example, if the current date is a day in December, the start date should be '2022-07-01', the end date should be '2022-09-30'. If the current date is a day in January, the start date should be '2022-10-01', the end date should be '2022-12-31'.
user
28-12-2022 12:28:45 -0500
code

1 Answer

Nevermind I have found the solution using sql below: addMonth(addday(current_date(),1-GETDAYOFYEAR(current_date())), (getquarter(current_date())-2)*3) as PREV_QTR_START_DATE, LASTDAYOFMONTH(addMonth(addday(current_date(),1-GETDAYOFYEAR(current_date())), (getquarter(current_date())-2)*3+2)) as PREV_QTR_END_DATE
user
28-12-2022 14:20:27 -0500
You must sign in to add an answer. If you do not have an account, you can register here