# 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:

Tagged:

• Coach

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.