How to find difference in years between two dates?

thebjorn BjornSteinarFjeldPettersen at gmail.com
Fri Jul 28 06:20:07 EDT 2006


John Machin wrote:
> Jan 31 to Feb 27: 27d (ex) 28d (in)
> Jan 31 to Feb 28: 28d (ex) 1m 1d (in)
> Jan 31 to Mar 01: 1m 1d (ex) 1m 2d (in)
> So 1 day short of 1m 1d is not 1m 0 d???

Exactly. Just as a person born on 1999-3-1 isn't a year old on
2000-2-29. Perfectly regular, consistent and reasonable.

> I'd call this unreasonable, inconsistent, anomalous -- especially
> when on the same website you do 1993-01-31 plus 1 month, it
> gives you 1993-02-28 (as I'd expect).

You're entitled to your opinion.

-- bjorn




More information about the Python-list mailing list