How To Return a Date N-Number of Quarters Ago

Sometimes you might need to create a scope of deals from the previous quarter or possibly even n-number of quarters ago.  Let's say for example you wanted to find all of the deals that closed between the beginning and the end of the last quarter.  How would you do this in Spiff?  

Finding a Date from the Statement Period

The first thing you will need is to get a concept of the current date.  In Excel, you can use a special function: Today().  In Spiff you can do something very similar by referencing the Statement Period object.  You can always get dates from the Statement Period.  The easiest way to do this is to write this in a formula:

statement_period.start_date

or 

statement_period.end_date

Finding the Beginning / End of the Current Quarter

But what if you want to find the start of the current calendar quarter?  Spiff has a nice built-in helper function that allows you to do this:

statement_period.beginning_of_current_quarter_date

or

statement_period.end_of_current_quarter_date

Great but now what if I want to find the beginning of the previous quarter?  Or even the beginning of 3 quarters ago?

Finding the Beginning / End of N-Quarters Ago

To do this we will need to combine another function with the concepts above.  We'll use a cool little function called months_ago.  

So to find the beginning of the last quarter, we can just write:

months_ago(statement_period.beginning_of_current_quarter_date, 3)

If we wanted to find the end of the last quarter, we can just write:

months_ago(statement_period.end_of_current_quarter_date, 3)

I bet you can guess how we would find the beginning of 2 quarters ago.  In this case, we would just "rewind" 6 months from the current statement period like this:

months_ago(statement_period.beginning_of_current_quarter_date, 6)

 


Did this help answer your question?

thumbs up
thumbs down

Thanks for the feedback! 🙏🏽