View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default compare dates using a variable

i need to know when 2 dates intersect
1-i begin with todays date and add a variable to it
2-i then subtract the same variable from a future date
3-i need to know at what date the 2 intersect

example: 7-16-2007 + 6=7-22-2007 5-10-2010 - 6=5-4-2010
then: 7-22-2007 + 6=7-28-2007 5-4-2010 - 6=4-28-2010,
etc
this loop continues until they intersect.


Since you are alternately adding and subtracting the same amount, the
intersection date will be midway between them (think about it). So, if one
date is in A1 and the other is in B1, then the "intersection" date would
be..

=(A1+B1)/2

For your dates, that would be 12/11/2008... from a mathematical standpoint,
the size of the variable is immaterial as long as it is small enough
compared to the span between the dates. But you should note that this is an
idealized mathematical solution, so it is possible (probably likely) that
the number of iteration required to meet will not be a whole number. As
Biff's pointed out in his posting to this thread, the granularity of the
variable determines if they physically meet or not, so you will have to
figure out how you want to handle this situation. Notice my calculated date
is roughly midway between the dates Biff posted.

Rick