raw math

Exploring Date Ratios

Robert Eisele

Last birthday, as I blew out the candles, a curious thought struck me: is there a precise moment in time when one person’s age is an exact multiple of another’s? More specifically, could there be a date when my mother was exactly twice as old as I was, precisely the age she was on the very day I was born?

From intuition to equation

At its heart, this question asks us to find a point in time \(x\) (measured in years) such that the ratio of two age spans equals a given fraction. If

then we want

\[ \frac{x - a}{x - b} \;=\;\frac{m}{n}. \]

Rearranging to solve for \(x\) gives the elegant formula

\[ x \;=\;\frac{a\,n \;-\; b\,m}{\,n - m\,}. \]

Plugging in our numbers (\(a = 1962\), \(b = 1988\), \(m = 2\), \(n = 1\)):

\[ x \;=\;\frac{1962 \times 1 \;-\; 1988 \times 2}{1 - 2} \;=\;\frac{1962 - 3976}{-1} \;=\;2014. \]

In other words, in the year 2014 our ages satisfy the 2:1 ratio—at least to the nearest year.

Refining with day-level precision

Since birthdays don’t fall exactly on January 1st, a year-only calculation is only approximate. To nail down the exact date, we can switch to counting days in SQL:

SELECT FROM_DAYS(
    2 * TO_DAYS('1988-01-23')   -- twice my birth-day count
  - TO_DAYS('1962-03-06')       -- minus my mother’s birth-day count
);

Running this on MySQL returns 2013-12-11, meaning that on December 11, 2013, my mother was exactly twice as old as I was.

Generalizing the solution

To handle any two birth dates and any integer ratio \(m:n\), you can wrap this logic in a stored function. Simply pass in the two dates and the two ratio factors, and the function will return the precise date when one age is \(m\) times the other.

CREATE FUNCTION find_date_ratio(a date, b date, m tinyint, n tinyint)
  RETURNS DATE DETERMINISTIC
RETURN FROM_DAYS((n * TO_DAYS(a) - m * TO_DAYS(b)) / (n - m));