Calculate Previous Quarter Start and End Date

Hello!

I am looking to calculate the Previous Quarter Start/End Date and the Previous Two Quarter Start/End Date.

For example:

Input:

November 8, 2022

Desired Output:

Previous Quarter Start Date - July 1, 2022

Previous Quarter End Date - September 30, 2022

Previous Two Quarter Start Date - April 1, 2022

Previous Two Quarter End Date - June 30, 2022


Work In Progress:


Answers

  • These are untested but something like this should get you what you're looking for:


    Previous Quarter Start Date

    LAST_DAY(`Report Date`) - INTERVAL (MOD(MONTH(`Report Date`), 3) + 3) MONTH + INTERVAL 1 DAY
    

    Previous Quarter End Date

    LAST_DAY(`Report Date`) - INTERVAL (MOD(MONTH(`Report Date`), 3)) MONTH
    

    Previous Two Quarter Start Date

    LAST_DAY(`Report Date`) - INTERVAL (MOD(MONTH(`Report Date`), 3) + 6) MONTH + INTERVAL 1 DAY
    

    Previous Two Quarter End Date

    LAST_DAY(`Report Date`) - INTERVAL (MOD(MONTH(`Report Date`), 3) + 3) MONTH
    


    LAST_DAY(`Report Date`)
    

    Returns the date of the last day in the month which you're aware of but clarifying it for others.


    MOD(MONTH(`Report Date`), 3)
    

    This tells us how many months to subtract to get to the prior quarter based on the Report Date's quarter. It's dividing the month number by three to get the remainder. For November it'll be 2. 11-2 = 9 (September)


     -  INTERVAL ... MONTH
    

    Subtract the specific number of months calculated above. Adding 3 to that number will take us back another entire quarter or 6 to go back two more quarters.


    + INTERVAL 1 DAY
    

    Add a day from the last day in the quarter 2 (+3 months) or 3 (+6 months) to get to the first day of the quarter 1 or 2 quarters ago.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Thank you for the response! I noticed however that I still receive the incorrect response. The function calculates the date from the previous quarter (Example, input is September 15, output is August 15, rather than expected output to be the first or the last day of the month of the quarter, July 1 or August 31)

    Workaround that I found is to build logic to determine the previous quarter, and then base on that information set the start and end dates of each quarter as they are constant.

  • @AddieB Can you share how you what format you used for the "previous quarter", and what formula you used to take the first date of that "previous quarter".

    Thank you!