My work entails that I have to calculate 6 thru 18 months back from a specific date. I have 2 examples.
Example 1:
My work asks me to calculate refunds from our clients. These refunds can only be 18 months at a time and the last date of the refund period is the day the letter goes out to the client. So, If the refund letter is set to be sent on August 28, 2012, What is the first date of that period? Also, what if it were August 29, 30, and 31st(08/28/2012 – 08/31/2012). My calculation would say that all of these time periods have March 1st, 2011 as their start date. I use SAS as the program tool. Here is the function I used:
eighteen_months = intnx('month',Visit_date,18,'sameday')+1;
The main assumption that I am making is 1 month is equal to the first date of the first month and the last date and that same month(01/01/2012 thru 01/31/2012). Subsequently, 3 months is equal to the first date of the first month and the last date of the 3rd month(01/01/2012 thru 03/31/2012 or 04/01/2012 thru 06/30/2012). Here are a couple of other 18 month Calculations:
First Date Last Date
10/30/1999 4/29/2001
5/6/2006 11/5/2007
4/30/2012 10/29/2013
4/3/2018 10/2/2019
2/24/2024 8/23/2025
5/10/2026 11/9/2027
The issue occurs in the case of my original example with August 28-31 where 18months can actually be 4 different time lengths.
Example 2:
My work also asks me to do the opposite where I have the first date and need figure out a 6 thru 18 month time period. I was recently asked what is 6 months if the first date is 06/22/2012? I responded with 12/21/2012 and was told that it is actually 12/22/2012. There is no real documentation/logic on how this is calculated in the company. Here is my function in SAS.
Six_months = intnx('month',Visit_date,6,'sameday')-1;
I am trying to establish a process and wanted to see if anyone runs into these processes on a consistent basis and if there is any easier way in Excel/SAS. Any responses would be greatly appreciated.
To get the First Date from Last Date in Excel try this formula where Last Date is in B2
=EDATE(B2,-18)+1That works for your 6 listed examples and also works to return 1st March 2011 from 28/29/30/31 August 2012
EDATE function, as you might guess, can be used to add or subtract a number of months from a date, if the day doesn’t exist within that month, like 30th Feb, then it defaults to the last day of that month