Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Calculate an Expiration Date depending on Purchase Dates for a Membership

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
This is hard to explain so I hope I can and that I've worded it correctly.

Need to calculate an expiration date:

row_nbr id purchase_date expiration date that needs to be calculated
1 1 03/29/2012 03/29/2013 - add 1 year
2 1 02/19/2013 03/29/2014 - since this member purchased their next membership BEFORE the 1st one expired, 2 years are added to the 1st purchase date
3 1 02/19/2014 03/29/2015 - since this member purchased their next membership BEFORE the 2nd one expired, 3 years are added to the 1st purchase date
4 1 02/17/2015 03/29/2016 - since this member purchased their next membership BEFORE the 3rd one expired, 4 years are added to the 1st purchase date

1 2 08/28/2013 08/28/2014 - add 1 year

1 3 08/28/2007 08/28/2008 - add 1 year
2 3 12/09/2008 12/09/2009 - since this member purchased their next membership AFTER the 1st one expired, 1 year is added to this 2nd purchase date
3 3 12/03/2009 12/09/2010 - since this member purchased their next membership BEFORE the 2nd one expired, 2 years is added to the 2nd purchase date
4 3 12/08/2010 12/09/2011 - since this member purchased their next membership BEFORE the 3rd one expired, 3 years are added to the 2nd purchase date
5 3 12/12/2011 12/12/2012 - since this member purchased their next membership AFTER the 4th one expired, 1 year is added to this 5th purchase date
6 3 12/17/2012 12/17/2013 - since this member purchased their next membership AFTER the 5th one expired, 1 year is added to this 6th purchase date
7 3 12/06/2013 12/17/2014 - since this member purchased their next membership BEFORE the 6th one expired, 2 years is added to the 6th purchase date
8 3 11/21/2014 12/17/2015 - since this member purchased their next membership BEFORE the 7th one expired, 3 years is added to the 6th purchase date
9 3 03/02/2016 03/02/2017 - since this member purchased their next membership AFTER the 8th one expired, 1 year is added to this 9th purchase date

1 4 08/25/2008 08/25/2009 - add 1 year
2 4 03/04/2010 03/04/2011 - since this member purchased their next membership AFTER the 1st one expired, 1 year is added to this 2nd purchase date
3 4 11/15/2010 03/04/2012 - since this member purchased their next membership BEFORE the 2nd one expired, 2 years is added to the 2nd purchase date
4 4 02/15/2012 03/04/2013 - since this member purchased their next membership BEFORE the 3rd one expired, 3 years is added to the 2nd purchase date
5 4 02/15/2013 03/04/2014 - since this member purchased their next membership BEFORE the 4th one expired, 4 years is added to the 2nd purchase date
6 4 03/26/2014 03/26/2015 - since this member purchased their next membership AFTER the 5th one expired, 1 year is added to this 6th purchase date
7 4 08/03/2015 08/03/2016 - since this member purchased their next membership AFTER the 6th one expired, 1 year is added to this 7th purchase date

Help would be very appreciated!
 
Why not just add 1 year to the last expiration date? It ends up being the same date, doesn't it?
 
It won't work if I understand what you are saying because like the example for id 4

row_nbr id purchase_date expiration date that needs to be calculated
1 4 08/25/2008 08/25/2009 - add 1 year
2 4 03/04/2010 03/04/2011 - since this member purchased their next membership AFTER the 1st one expired, 1 year is added to this 2nd purchase date
3 4 11/15/2010 03/04/2012 - since this member purchased their next membership BEFORE the 2nd one expired, 2 years is added to the 2nd purchase date
4 4 02/15/2012 03/04/2013 - since this member purchased their next membership BEFORE the 3rd one expired, 3 years is added to the 2nd purchase date

5 4 02/15/2013 03/04/2014 - since this member purchased their next membership BEFORE the 4th one expired, 4 years is added to the 2nd purchase date

6 4 03/26/2014 03/26/2015 - since this member purchased their next membership AFTER the 5th one expired, 1 year is added to this 6th purchase date

7 4 08/03/2015 08/03/2016 - since this member purchased their next membership AFTER the 6th one expired, 1 year is added to this 7th purchase date

Row 5: If I add 1 year to this expiration date 03/04/2014 then row 6 would have an expiration date of 03/04/2015 but it has to be 03/26/2015 since the next purchase date of 03/26/2014 is after 03/04/2014.

Thanks
 
You'll need to explain #4, because on the surface it looks the same as #3. The purchase was one year plus change prior to the expiration, so what makes that a +4 instead of a +3?
 
I'm sorry, I should have said the purchase date. Why not add 1 year to the last purchase date?
If purchase date > expiration date Then add 1 year to purchase date
else add 1 year to expiration date
 
Hi Charliy,

Row 4 would be +3 because they purchased their 2nd one on 03/04/2010 and that is after the 08/25/2009 (row 1) expiration date. This is hard to explain. How the next expiration date is calculated depends if they purchased their next membership before or after their previous expiration date.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top